I am writing a test to test evm contract instantiation using polkadot api.

I get to derive the evm account like this:

const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
const aliceEthAccount = addressToEvm(alice.addressRaw);

where addressToEvm is an helper function from @polkadot/util-crypto

This piece of code from frontier does the conversion from H160 to AccountId on chain

fn into_account_id(address: H160) -> AccountId32 {
        let mut data = [0u8; 24];
        let hash = H::hash(&data);

        AccountId32::from(Into::<[u8; 32]>::into(hash))

But then when i feed the aliceEthAccount to my extrinsic to instantiate the evm contract, i get an address which does not correspond to my alice substrate address, which makes the origin wrong and also funds cannot be withdrawn from that wrong generated address.

Am i missing something? or is the way i am generating the H160(ethereum account) address wrong?

1 Answer 1


There isn’t Alice or Bob in H160.

Use these instead:

        "name": "Alith",
        "p": "0x02509540919faacf9ab52146c9aa40db68172d83777250b28e4679176e49ccdd9f",
        "s": "0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133"
        "name": "Baltathar",
        "p": "0x033bc19e36ff1673910575b6727a974a9abd80c9a875d41ab3e2648dbfb9e4b518",
        "s": "0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b"
        "name": "Charleth",
        "p": "0x0234637bdc0e89b5d46543bcbf8edff329d2702bc995e27e9af4b1ba009a3c2a5e",
        "s": "0x0b6e18cafb6ed99687ec547bd28139cafdd2bffe70e6b688025de6b445aa5c5b"
        "name": "Dorothy",
        "p": "0x02a00d60b2b408c2a14c5d70cdd2c205db8985ef737a7e55ad20ea32cc9e7c417c",
        "s": "0x39539ab1876910bbf3a223d84a29e28f1cb4e2e456503e7e91ed39b2e7223d68"
        "name": "Ethan",
        "p": "0x025cdc005b752651cd3f728fb9192182acb3a9c89e19072cbd5b03f3ee1f1b3ffa",
        "s": "0x7dce9bc8babb68fec1409be38c8e1a52650206a7ed90ff956ae8a6d15eeaaef4"
        "name": "Faith",
        "p": "0x037964b6c9d546da4646ada28a99e34acaa1d14e7aba861a9055f9bd200c8abf74",
        "s": "0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df"

These built in keys can also be found at https://github.com/polkadot-js/common.

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.