Table of Contents
To get a local copy up and running follow these simple example steps.
- Open brush required that I use rust nightly but building the contract required stable.
- A pre-requisite for compiling smart contracts is to have a stable Rust version and Cargo installed. Here's an installation guide.
- The first tool we will be installing is cargo-contract, a CLI tool for helping setting up and managing WebAssembly smart contracts written with ink!.
By default, cargo-contract builds the contract in debug mode. This means that the contract will e.g. print statements like
ink::env::debug_println!("magic number: {}", value);
to the node's console if debugging was enabled on the node (instructions here). To support functionality like this the debug build of a contract includes some heavy-weight logic.
For contracts that are supposed to run in production you should always build the contract with --release:
cargo +stable contract build --release
This will ensure that nothing unnecessary is compiled into the Wasm blob, making your contract faster and cheaper to deploy and execute.
The substrate-contracts-node is a simple Substrate blockchain which is configured to include the Substrate module for smart contract functionality โ the contracts pallet (see How it Works for more). It's a comfortable option if you want to get a quickstart. Download the binary here.
After successfully installing substrate-contracts-node, you can start a local development chain by running:
substrate-contracts-node
You can interact with your node using the Contracts UI. Once you have the webpage open, click on the dropdown selector at the top left corner and choose "Local Node".
Note that blocks are only created when you execute a function in substrate-contracts-node, so trigger a another function first if a function depends on a time delay.
- https://github.com/paritytech/ink-examples/blob/main/contract-transfer/lib.rs
- https://github.com/paritytech/ink
- https://learn.brushfam.io/docs/OpenBrush/smart-contracts/ownable
- https://github.com/Brushfam/openbrush-contracts/blob/main/lang/src/test_utils.rs#L39
- https://github.com/Brushfam/openbrush-contracts/blob/main/contracts/src/access/ownable/mod.rs
- https://github.com/Supercolony-net/openbrush-contracts/blob/96b556536a9806cb2a0db7a6159a412754ceba9b/contracts/src/traits/errors/psp22.rs#L100
- https://paritytech.github.io/ink/ink_env/test/index.html
- https://use.ink/basics/contract-testing/
- https://use.ink/examples/smart-contracts
- https://use.ink/getting-started/building-your-contract
- https://substrate.stackexchange.com/questions/1174/why-is-it-a-bad-idea-to-use-string-in-an-ink-smart-contract