Life cycle of a smart contract#

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.

flow diagram with different actions
  1. In cargo-concordium run the init command to start a new project.

  2. 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.

  3. In cargo-concordium run the build command to build the Wasm module that can be deployed on chain.

  4. In concordium-client run the deploy command to deploy the Wasm module. This makes the contract available on chain.

  5. 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.

  6. 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.