Skip to content

use-ink/ink

Folders and files

NameName
Last commit message
Last commit date
Dec 5, 2024
Mar 10, 2025
Mar 21, 2025
Mar 13, 2025
Mar 21, 2025
Mar 21, 2025
Mar 18, 2025
Mar 21, 2025
Mar 11, 2019
Nov 28, 2024
Jan 16, 2025
Mar 21, 2025
Mar 19, 2025
Nov 13, 2024
Jan 9, 2025
Jan 16, 2025
Mar 19, 2025
Mar 19, 2025
Apr 26, 2024
May 4, 2020
Dec 9, 2022
Mar 21, 2025
Jan 28, 2025
Jan 28, 2025

Repository files navigation

ink!

Write smart contracts in Rust for Polkadot SDK.

linux codecov coveralls loc
stack-exchange telegram X

ink! Website  •   Developer Documentation

Getting started

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

Architecture & How It Works

The architecture of ink! is documented in the code and in this file: ARCHITECTURE.md.

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(signature_topic = _)] Applicable to ink! events. Specifies custom signature topic of the event that allows to use manually specify shared event definition.
#[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.

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_e2e End-to-End testing framework for contracts.
ink_env Low-level interface for interacting with the smart contract executor. Contains the off-chain testing API as well.
ink_storage Data structures available in ink!.
ink_prelude Common API for no_std and std to access alloc crate types.

Community Badges

Normal Design

Built with ink!

[![Built with ink!](https://raw.githubusercontent.com/use-ink/ink/master/.images/badge.svg)](https://github.com/use-ink/ink)

Flat Design

Built with ink!

[![Built with ink!](https://raw.githubusercontent.com/use-ink/ink/master/.images/badge_flat.svg)](https://github.com/use-ink/ink)

Contributing

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.

License

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