cennznet / cennznet/api.js

support evm update

Open
#411 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
10
Forks
9
PR merge metrics
No merged PRs in 30d

Description

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:
```js
await ApiPromise.create({
provider,
signedExtensions: {
'ChargeTransactionPayment': {
extrinsic: {
tip: 'Compact',
feeExchange: 'Option',
},
payload: {},
}
}
}
```

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

```js
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);
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.