This project template is designed for the [Sylvia framework], a comprehensive tool for building CosmWasm smart contracts.(https://github.com/CosmWasm/sylvia).
Before you begin, ensure cargo-generate
is installed on your system.
cargo install cargo-generate
Generate a new project using:
cargo generate CosmWasm/sylvia-template
Alternatively, specify your project's name directly:
cargo generate CosmWasm/sylvia-template -n my-contract
The Sylvia framework aims to minimize boilerplate code in contract development. By utilizing a few procedural macros, it allows developers to concentrate on the core business logic of the contract. The Sylvia book is an excellent resource for getting started.
This template repository includes a sample contract and scripts to assist in the development process.
Cargo scripts can be run without any additional tools other than the cargo itself. They are a useful aliases for the more complex commands:
cargo wasm
- compiles the Wasm release binary,cargo wasm-debug
- compiles the Wasm debug binary, useful for testing,cargo schema
- generates JSON schema of the contract's messages.
Post-compilation, validate the Webassembly binary's integrity using cosmwasm-check. A user guide is available on the crates.io repository.
The contracts generated by Sylvia can be also used as part of other contracts. For this reason, there's a feature flag provided in this repository called library
. It prevents Sylvia from generating entry points for the contract so that it can be used as a dependency. Without that feature, using a contract in some other crate can cause a collision with the main contract's entry points. More info is available in the Sylvia Book.
Sylvia-built contracts can also be integrated as dependencies in other contracts. The library
feature flag in this repository omits entry point generation, allowing the contract to function as a dependency. Activating this feature prevents entry point collisions when using the contract in another crate. More details are in the Sylvia Book.
Syvlia supports multiple testing methods, including unit tests and multitests, without a blockchain testing environment. Examples of both are provided in this template.
The template itself is licensed under the Apache 2.0 license. After generating, no license file is included with your new project - you might want to add one if you're making your source code publically available!