Skip to main content
Version: 5.x

This attribute supports a niche case that is rarely needed.

Can be applied on ink! implementation blocks in order to make ink! aware of them. This is useful if such an implementation block doesn't contain any other ink! attributes, so it would be flagged by ink! as a Rust item. Adding #[ink(impl)] on such implementation blocks makes them treated as ink! implementation blocks thus allowing to access the environment etc.

Note that ink! messages and constructors still need to be explicitly flagged as such.


An implementation block can be defined as a trait implementation for the ink! storage struct using the #[ink(impl)] annotation ‒ even if none of its interior items have any ink! specific attributes on them:

use core::convert::TryFrom;

mod my_module {
pub struct MyStorage {
/* storage fields */

impl MyStorage {
fn my_method(&self) -> i32 {
/* method implementation */

impl MyStorage {
pub fn my_constructor() -> Self {
/* constructor implementation */

pub fn my_message(&self) {
/* message implementation */