Function createERCDepositData

  • Constructs the deposit data for an EVM-Substrate bridge transaction.

    Example

    // Amount of tokens:
    const amount = '1';
    // EVM address
    const evmAddress = '0x1234567890123456789012345678901234567890';
    // Decimals of the token
    const decimals = 18;
    createERCDepositData(amount, evmAddress, decimals);

    Example

    import { decodeAddress } from '@polkadot/util-crypto';
    // Substrate MultiLocation
    // Decode address to bytes of public key
    const addressPublicKeyInBytes = decodeAddress(
    '5CDQJk6kxvBcjauhrogUc9B8vhbdXhRscp1tGEUmniryF1Vt',
    );
    // Convert bytes of public key to hex string
    const addressPublicKeyHexString = ethers.utils.hexlify(addressPublicKeyInBytes);
    // console.log(addressPublicKeyHexString) => "0x06a220edf5f82b84fc5f9270f8a30a17636bf29c05a5c16279405ca20918aa39"
    const multiLocation = JSON.stringify({
    parents: 0,
    interior: {
    X1: {
    AccountId32: {
    network: { any: null },
    id: addressPublicKeyHexString,
    },
    },
    },
    })
    // Amount of tokens:
    const amount = '2';
    createERCDepositData(amount, multiLocation);

    Returns

    The deposit data as hex string

    Parameters

    • tokenAmount: string

      The amount of tokens to be transferred.

    • recipientAddress: string

      The address of the recipient.

    • Optional decimals: number = 18

      The number of decimals of the token.

    Returns string

Generated using TypeDoc