Crates.io serves as a centralized repository for Rust packages, also known as "crates." When building applications or libraries with Rust, developers often need to use external libraries for functionality not provided by the standard library, many of which are included on Crates.io. Below is an example of how to import Secret Labs' crates, such as secret-cosmwasm-std
, a fork of the original cosmwasm-storage
repository adapted for use in SecretNetwork's Secret Contracts.
You can think of "crates" as individual packages or modules in Rust, while "dependencies" refer to external crates that your project relies on for additional functionality.
When developing a Rust project, you will often have dependencies on other crates. These dependencies can come from crates.io (the default Rust package registry), a Git repository (such as one hosted by Secret Labs!), or a local path on your system. The Rust package manager, Cargo, is responsible for managing these dependencies, ensuring that the correct versions are fetched and built, and handling transitive dependencies (i.e., the dependencies of your dependencies).
Crates: A crate is a package or a module in Rust containing code and resources, like libraries or applications. Crates are the building blocks of Rust projects and are intended to be easily shared and reused. A crate can be a binary (application) or a library. Each crate has a unique name and a Cargo.toml
file containing metadata, such as the crate's name, version, authors, and dependencies.
Dependencies: Dependencies refer to external crates that your Rust project or library relies on for additional functionality. These external crates are not part of your project's codebase but are required for your project to build and function correctly. Dependencies are declared in the Cargo.toml
file of your project under the [dependencies]
section.
Environment configuration instructions to get started developing on Secret Network.
Secret Contracts are written using the CosmWasm framework. CosmWasm contracts are written in Rust, which is later compiled to WebAssembly (or WASM for short). To write our first Secret Contract, we need to set up a development environment with all of the tools required so that you can upload, instantiate, and execute your smart contracts.
For a step-by-step Secret Network environment configuration video tutorial, follow along here 🎥. Otherwise, continue reading!
To follow along with the guide, we will be using git
, make
, rust
, and docker
.
Install git
:
Download the latest Git for Mac installer.
Follow the prompts to install Git.
Open a terminal and verify the installation was successful by typing git --version
Install make
:
Install git
and perl
(for Windows):
Go to https://git-scm.com/download/win and the download will start automatically. Note that this is a project called Git for Windows, which is separate from Git itself; for more information on it, go to https://gitforwindows.org.
Go to https://strawberryperl.com and download the recommended version for your system. StrawberryPerl is an open-source Perl environment for Windows; for more information, visit https://perl.org. Perl is used to build other dependencies that will be installed later.
Note: support for make
on Windows is limited, so we'll provide separate commands for Windows where necessary
Download and run rustup-init.exe
.
Download and run the Rust .msi installer
Having Trouble? You might need to restart your terminal, or run a command like:
source "$HOME/.cargo/env"
After installing Rust to configure the current shell
Cargo generate is the tool you'll use to create a smart contract project. Learn more about cargo-generate
here.
Docker is an open platform for developing, shipping, and running applications.
SecretCLI is a command-line tool that lets us interact with the Secret Network blockchain. It is used to send and query data as well as manage user keys and wallets.
Run the following commands in Powershell to download the latest version of SecretCLI and add it to your profile's PATH:
Afterwards, restart the terminal and test the installation with the following command:
For a more detailed and in-depth guide on SecretCLI installation and usage, check out the documentation here.
Now it's time to learn how to compile and deploy your first smart contract 🎉