Skip to content

support evm update #411

Description

@jordy25519

With cennznet 2.1.0 type definitions are no longer necessary (except for backwards compatibility and possibly TS definition generation)

using @polkadot/api latest & this snippet is enough to read and sign transactions successfully on CENNZnet:

await ApiPromise.create({
      provider,
      signedExtensions: {
        'ChargeTransactionPayment': {
          extrinsic: {
            tip: 'Compact<Balance>',
            feeExchange: 'Option<u32>',
          },
          payload: {},
        }
      }
}

additionally, this function should be added to convert Ethereum addresses to CENNZnet 32 byte format

function cvmToAddress(evmAddress) {
  var message = utils.stringToU8a('cvm:');
  message = utils.u8aConcat(message, new Array(7).fill(0), utils.hexToU8a(evmAddress));
  let checkSum = message.reduce((a, b) => a ^ b, 0);
  message = utils.u8aConcat(message, new Array(1).fill(checkSum));

  return utilCrypto.encodeAddress(message, 42);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions