Skip to main content
Version: v6
Attention!You are viewing unreleased ink! 6 docs. Click here to view the latest docs.

Environment Title Picture

Chain Environment Types

ink! defines a trait Environment and also a default implementation of that trait ‒ DefaultEnvironment.

These are the types that ink! uses, if no explicit steps are taken:

/// The fundamental types of the default configuration.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(TypeInfo))]
pub enum DefaultEnvironment {}

impl Environment for DefaultEnvironment {
const MAX_EVENT_TOPICS: usize = 4;

type AccountId = AccountId;
type Balance = Balance;
type Hash = Hash;
type Timestamp = Timestamp;
type BlockNumber = BlockNumber;
type ChainExtension = NoChainExtension;
type EventRecord = EventRecord;
}

The context here is that you can use ink! on any blockchain that was built with the Polkadot SDK and includes the pallet-revive module.

Chains built with the Polkadot SDK can decide on their own which types they want to use for e.g. the chain's block number or account id's. For example, chains that intend to be compatible to Ethereum typically use the same type as Ethereum for their AccountId.

Most Polkadot SDK chains stay with the default types though and ink! just uses those by default as well. It is possible to configure a different environment in the contract macro (documentation here) though:

#[ink::contract(env = MyCustomTypes)]
caution

If you write a contract for a chain that deviates from our default types (DefaultEnvironment), you have to make sure to configure that chain's Environment for your contract!