Wondering if anyone knows whether ink! supports AccountIds which are ethereum-style accounts? Let's assume this would be a chain with a Unified Accounts setup, similar to Moonbeam. In specific, we could assume this would be a chain whose runtime's AccountId type comes from a signature type also similar to Moonbeam's.

If it is supported, are there any important considerations?

2 Answers 2


Wondering if anyone knows whether ink! supports AccountIds which are ethereum-style accounts?

Yes. pallet-contracts will work with the unified account setup you referenced. It is generic over the AccountId. The type is defined chain wide in frame_system::pallet::Config.

For example, Moonbeam would have no problem integrating pallet-contracts. It will just work with their customized AccountId.

If it is supported, are there any important considerations?

While the AccountId is generic, it is still rare for chains to actually deviate from the default type. Hence most ink! contracts probably hard code or at least have some assumptions about the used AccountId. An ink! contract needs to be configured in order to learn about which types a chain uses.

Hence you need to change and re-compile a contract for each target chain that uses a different environment. Changing the contract code in order to compile it for different environments is quite annoying. You could introduce a cargo feature for your contract which would allow you to select different environments when compiling using --features.

Like this:

#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "std", derive(TypeInfo))]
#[cfg(feature = "moonbeam")]
pub enum MoonbeamEnvironment {}

#[cfg(feature = "moonbeam")]
impl ink_env::Environment for MoonbeamEnvironment {
    // Configure for moonbeam.
    // `type AccountId` would be the interesting item

#[cfg(feature = "moonbeam")]
type MyEnv = MoonbeamEnvironment;

#[cfg(not(feature = "moonbeam"))]
type MyEnv = ink_env::DefaultEnvironment;

#[ink::contract(env = MyEnv)]
  • Ah thank you - this helps me pre-empt a possible issue Commented Mar 31, 2023 at 19:34
  • If you want a single contract to work on chains with different environments you could use cargo features. Added an example. Commented Mar 31, 2023 at 21:25

You can use Ethereum accounts in ink! as long as pallet-contracts is present.

You can use ink! on any blockchain that was built with the Substrate framework and includes the pallet-contracts module. Substrate does not define specific types for a blockchain, it uses generic types throughout. Chains built on Substrate 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.


Edit: I don't believe there any important considerations, it "just works" out of the box.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.