Introduction to smart contracts#

Already know what smart contracts are? Go to the quick guide to start building smart contracts on Concordium right away.

A smart contract is a user-supplied piece of code submitted to the Concordium blockchain, used to define behavior that is not directly part of the core protocol. Smart contracts are executed by nodes in the Concordium network according to predefined rules. Their execution is fully transparent, and all nodes must agree on what the outcome of execution is based on only publicly available information.

A smart contract can receive, hold and send CCD, it is able to observe some aspects of the chain, and maintain its own state. Smart contracts are always executed as a response to external actions, e.g., an account sending a message. In practice, smart contracts will often be a small part of a larger system, combining on and off-chain functionality. An example of off-chain functionality could be a server that invokes the smart contract based on data from the real-world, such as prices of stocks, or weather information.

Smart contracts can reduce the needed amount of trust in third-parties, in some cases removing the need for a trusted third-party, in other cases reducing their capabilities and thus reducing the amount of trust needed in them.

Because smart contracts are executed completely transparently, in a way that anybody with access to a node can verify, they can be very useful for ensuring agreement between parties.

Auction smart contract example#

A use case for smart contracts could be for holding an auction; here you program the smart contract to accept different bids from anyone and have it keep track of the highest bidder. When the auction is over, the smart contract sends the winner bid CCD to the seller and all other bids back. The seller then should send the item to the winner.

The smart contract replaces the main role of the auctioneer. The contract itself only governs the bidding part, and the on-chain distribution of CCDs. It will likely also need some logic for reimbursing the highest bidder if the seller does not fulfil their obligations. This will most likely mean that the contract needs to support some notion of proof that the seller has indeed fulfilled their obligation, or some way for the highest bidder to file a complaint. Smart contracts cannot resolve these real-world issues automatically, and the best solution is likely going to depend on the specifics of the auction.

Next steps#

Additional reading#

For information about the lifecycle of smart contracts, see Lifecycle of a smart contract. You can also continue reading about contract modules, contract instances, and contract schemas. Also, read the Smart contracts best practices.

Smart contract development tools#

Concordium provides a number of tools to simplify the smart contract creation and deployment process.

The VSCode extension can help you develop Concordium smart contracts. The extension sets up the editor for development, installs the cargo-concordium smart contract development tool for all supported platforms, and provides commands in the editor for the essential workflows, such as building and testing smart contracts.

You can watch a video about how to use the VSCode extension.

The integration testing library simplifies testing of your smart contracts before deployment.

The main library for Smart contract development can be found on

To ease deployment and initialization, you can use the Smart contract deploy and initialize tool. It works with the Concordium Wallet for Web to deploy and initialize smart contracts to Mainnet and Testnet.

The Typescript smart contract client generator helps you generate JavaScript or TypeScript clients for the Concordium blockchain.