Life cycle#
A smart contract is first deployed to the chain as part of a contract module. After this a smart contract can be initialized to obtain a smart contract instance. Finally a smart contract instance can be repeatedly updated according to its own logic. Before you can follow this guide, you need to setup the development environment.
In
cargo-concordium
run the init command to start a new project.Edit your contract, including the entrypoints, functions, and parameters necessary to execute what is needed. If using a schema, make sure that the contract is prepared for this. You can also run your code off-chain for testing purposes with the integration testing library.
In
cargo-concordium
run the build command to build the Wasm module that can be deployed on chain.In
concordium-client
run the deploy command to deploy the Wasm module. This makes the contract available on chain.In
concordium-client
run the init command to initialize the contract on chain. This gives you a new instance of the smart contract with a fresh state.In
concordium-client
you can then run invoke to simulate your contract and see how much energy it uses or to call a view entrypoint which returns some data derived from the contract state; use show to see the schema or parameters in the contract, or update to execute transactions and update the state.
You can also watch a video about the smart contract lifecycle.