Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support evm update #411

Open
jordy25519 opened this issue Jan 26, 2022 · 0 comments
Open

support evm update #411

jordy25519 opened this issue Jan 26, 2022 · 0 comments

Comments

@jordy25519
Copy link
Contributor

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant