Parity's ink! to write smart contracts.
Alternatives To Ink
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
a day ago429gpl-3.0C++
Solidity, the Smart Contract Programming Language
a month ago95otherJavaScript
Mastering Ethereum, by Andreas M. Antonopoulos, Gavin Wood
Truffle13,9392,4421,32113 hours ago466September 22, 2022532mitTypeScript
A tool for developing smart contracts. Crafted with the finest cacaos.
Full Blockchain Solidity Course Py9,725
2 months ago212mit
Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
Full Blockchain Solidity Course Js8,660
a month ago45
Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
Defi Developer Road Map8,598
16 days ago1otherJavaScript
DeFi Developer roadmap is a curated Developer handbook which includes a list of the best tools for DApps development, resources and references!
Wtf Solidity7,378
4 days ago6otherSolidity
我最近在重新学solidity,巩固一下细节,也写一个“WTF Solidity极简入门”,供小白们使用,每周更新1-3讲。官网:
Smart Contract Best Practices6,703
4 months ago22
A guide to smart contract security best practices
Hardhat5,835201,300a day ago98September 23, 2022415otherTypeScript
Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
Aptos Core5,2268111 hours ago12August 16, 2022298otherRust
Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
Alternatives To Ink
Select To Compare

Alternative Project Comparisons

Parity's ink! for writing smart contracts

linux codecov coveralls loc stack-exchange

squink, the ink! mascotink! is an eDSL to write smart contracts in Rust for blockchains built on the Substrate framework. ink! contracts are compiled to WebAssembly.

Guided Tutorial for Beginners  •   ink! Documentation Portal  •   Developer Documentation

More relevant links:

Table of Contents

Play with It

The best way to start is to check out the Getting Started page in our documentation.

If you want to have a local setup you can use our substrate-contracts-node for a quickstart. It's a simple Substrate blockchain which includes the Substrate module for smart contract functionality ‒ the contracts pallet (see How it Works for more).

We also have a live testnet named "Contracts" on Rococo. Rococo is a Substrate based parachain which supports ink! smart contracts. For further instructions on using this testnet, follow the instructions in our documentation.

The Contracts UI can be used to instantiate your contract to a chain and interact with it.


A prerequisite for compiling smart contracts is to have Rust and Cargo installed. Here's an installation guide.

We recommend installing cargo-contract as well. It's a CLI tool which helps set up and manage WebAssembly smart contracts written with ink!:

cargo install cargo-contract --force

Use the --force to ensure you are updated to the most recent cargo-contract version.

In order to initialize a new ink! project you can use:

cargo contract new flipper

This will create a folder flipper in your work directory. The folder contains a scaffold Cargo.toml and a, which both contain the necessary building blocks for using ink!.

The contains our hello world contract ‒ the Flipper, which we explain in the next section.

In order to build the contract just execute this command in the flipper folder:

cargo contract build

As a result you'll get a target/flipper.wasm file, a flipper.json file and a <contract-name>.contract file in the target folder of your contract. The .contract file combines the Wasm and metadata into one file and needs to be used when instantiating the contract.

Hello, World! ‒ The Flipper

The Flipper contract is a simple contract containing only a single bool value.

It provides methods to:

  • flip its value from true to false (and vice versa) and
  • return the current state.

Below you can see the code using ink!.

mod flipper {
    /// The storage of the flipper contract.
    pub struct Flipper {
        /// The single `bool` value.
        value: bool,

    impl Flipper {
        /// Instantiates a new Flipper contract and initializes
        /// `value` to `init_value`.
        pub fn new(init_value: bool) -> Self {
            Self {
                value: init_value,

        /// Flips `value` from `true` to `false` or vice versa.
        pub fn flip(&mut self) {
            self.value = !self.value;

        /// Returns the current state of `value`.
        pub fn get(&self) -> bool {

    /// Simply execute `cargo test` in order to test your contract
    /// using the below unit tests.
    mod tests {
        use super::*;

        fn it_works() {
            let mut flipper = Flipper::new(false);
            assert_eq!(flipper.get(), false);
            assert_eq!(flipper.get(), true);

The flipper/src/ file in our examples folder contains exactly this code. Run cargo contract build to build your first ink! smart contract.


In the examples repository you'll find a number of examples written in ink!.

Some of the most interesting ones:

  • basic_contract_ref ‒ Implements cross-contract calling.
  • trait-erc20 ‒ Defines a trait for Erc20 contracts and implements it.
  • erc721 ‒ An exemplary implementation of Erc721 NFT tokens.
  • dns ‒ A simple DomainNameService smart contract.
  • …and more, just rummage through the folder 🙃.

To build a single example navigate to the root of the example and run:

cargo contract build

You should now have an <name>.contract file in the target folder of the contract.

For information on how to upload this file to a chain, please have a look at the Play with It section or our smart contracts workshop.

How it Works

  • Substrate's Framework for Runtime Aggregation of Modularized Entities (FRAME) contains a module which implements an API for typical functions smart contracts need (storage,querying information about accounts, …). This module is called the contracts pallet,
  • The contracts pallet requires smart contracts to be uploaded to the blockchain as a Wasm blob.
  • ink! is a smart contract language which targets the API exposed by contracts. Hence ink! contracts are compiled to Wasm.
  • When executing cargo contract build an additional file <contract-name>.json is created. It contains information about e.g. what methods the contract provides for others to call.

ink! Macros & Attributes Overview

Entry Point

In a module annotated with #[ink::contract] these attributes are available:

Attribute Where Applicable Description
#[ink(storage)] On struct definitions. Defines the ink! storage struct. There can only be one ink! storage definition per contract.
#[ink(message)] Applicable to methods. Flags a method for the ink! storage struct as message making it available to the API for calling the contract.
#[ink(constructor)] Applicable to method. Flags a method for the ink! storage struct as constructor making it available to the API for instantiating the contract.
#[ink(event)] On struct definitions. Defines an ink! event. A contract can define multiple such ink! events.
#[ink(anonymous)] Applicable to ink! events. Tells the ink! codegen to treat the ink! event as anonymous which omits the event signature as topic upon emitting. Very similar to anonymous events in Solidity.
#[ink(topic)] Applicable on ink! event field. Tells the ink! codegen to provide a topic hash for the given field. Every ink! event can only have a limited number of such topic fields. Similar semantics as to indexed event arguments in Solidity.
#[ink(payable)] Applicable to ink! messages. Allows receiving value as part of the call of the ink! message. ink! constructors are implicitly payable.
#[ink(selector = S:u32)] Applicable to ink! messages and ink! constructors. Specifies a concrete dispatch selector for the flagged entity. This allows a contract author to precisely control the selectors of their APIs making it possible to rename their API without breakage.
#[ink(selector = _)] Applicable to ink! messages. Specifies a fallback message that is invoked if no other ink! message matches a selector.
#[ink(namespace = N:string)] Applicable to ink! trait implementation blocks. Changes the resulting selectors of all the ink! messages and ink! constructors within the trait implementation. Allows to disambiguate between trait implementations with overlapping message or constructor names. Use only with great care and consideration!
#[ink(impl)] Applicable to ink! implementation blocks. Tells the ink! codegen that some implementation block shall be granted access to ink! internals even without it containing any ink! messages or ink! constructors.

See here for a more detailed description of those and also for details on the #[ink::contract] macro.

Trait Definitions

Use #[ink::trait_definition] to define your very own trait definitions that are then implementable by ink! smart contracts. See e.g. the examples/trait-erc20 contract on how to utilize it or the documentation for details.

Off-chain Testing

The #[ink::test] procedural macro enables off-chain testing. See e.g. the examples/erc20 contract on how to utilize those or the documentation for details.

Developer Documentation

We have a very comprehensive documentation portal, but if you are looking for the crate level documentation itself, then these are the relevant links:

Crate Docs Description
ink Language features exposed by ink!. See here for a detailed description of attributes which you can use in an #[ink::contract].
ink_storage Data structures available in ink!.
ink_env Low-level interface for interacting with the smart contract Wasm executor. Contains the off-chain testing API as well.
ink_prelude Common API for no_std and std to access alloc crate types.

Community Badges

Normal Design

Built with ink!

[![Built with ink!](](

Flat Design

Built with ink!

[![Built with ink!](](


Visit our contribution guidelines for more information.

Use the scripts provided under scripts/check-* directory in order to run checks on either the workspace or all examples. Please do this before pushing work in a PR.


The entire code within this repository is licensed under the Apache License 2.0.

Please contact us if you have questions about the licensing of our products.

Popular Smart Contracts Projects
Popular Blockchain Projects
Popular Blockchain Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Smart Contracts
Domain Specific Language