The Cudos Network uses CosmWasm as a framework for developing smart contracts and infrastructure to run them on chain. Smart contracts are written using Rust.
In order to develop smart contracts, you need the Rust toolchain.
Rust is a statically-typed programming language designed for performance and safety, especially safe concurrency and memory management. Its syntax is similar to that of C++. It is an open-source project developed originally at Mozilla Research.
Rust design principles minimise smart contract vulnerabilities by using existing frameworks such as WebAssembly (wasm).
WebAssembly is a small, fast, efficient and very secure, stack-based virtual machine that is CPU and OS neutral. It is designed to execute portable bytecode — compiled from code at near-native speed. Sandboxed environment means can run in any environment. WASM programming language support is extensive and growing.
CosmWasm is a smart contract platform built for the Cosmos ecosystem (of which Cudos is a member). It is is the Cosmos (Cosm) way of using WebAssembly (Wasm) hence the name.
CosmWasm provides API and library functions such as verifying addresses and more advanced storage items. These enable you to write powerful smart contracts.
Install Rust and WASM
- Install the latest version of Rust
Follow the instructions to configure the
PATH environment variable.
- Verify installation
You should get a message similar to this:
rustc 1.61.0 (fe5b13d68 2022-05-18)
- Run the following commands
// Set 'stable' as the default release channel:
rustup default stable
// Add WASM as the compilation target:
rustup target add wasm32-unknown-unknown
// Install the following package to run custom cargo scripts:
cargo install cargo-generate --features vendored-openssl
cargo install cargo-run-script
Cargo is the Rust build system and package manager. It is a great tool to manage Rust projects because it builds your code, downloads the libraries your code depends on, and builds those libraries or dependencies.
Set up command-line tools
apt install jq curl
You are now ready build!