Actions
  Aventus testnet testing » History » Revision 2
      « Previous |
    Revision 2/4
      (diff)
      | Next »
    
    Olivier Bitsch, 02/02/2022 10:02 AM 
    
    
Aventus testnet testing¶
AvN gateway details¶
- Gateway URL: testnet.gateway.aventus.io
- Relayer Public key: 0x7075f2ec5abe24801ce8ccb2e7ffb13284df44c7baa9a583f8fd2f0498edb547
- Relayer Address: 5EcAFwVcBo8s2D3ZSTnx2sq49wVDF3rc1yGJMx5nRp2GsK62
AvN account generation¶
There are multiple ways of generating accounts to interact with the AvN blockchain. This document will highlight 2 of them.
Polkadot libraries can be used to generate accounts that are compatible with the AvN. The following example code demonstrates this.
index.js
const { Keyring } = require('@polkadot/keyring');
const { u8aToHex } = require('@polkadot/util');
const { cryptoWaitReady, mnemonicGenerate, mnemonicToMiniSecret } = require('@polkadot/util-crypto');
async function generateAccount(accountCrypto) {
 let crypto = accountCrypto || 'sr25519';
 if (!['ed25519', 'sr25519'].includes(crypto)) {
   throw (`Invalid account crypto "${crypto}" specified.`);
 }
 await cryptoWaitReady();
 const keyring = new Keyring({ type: crypto, ss58Format: 42 });
 const mnemonic = mnemonicGenerate();
 const keyPair = keyring.createFromUri(mnemonic);
 const key = {
   'Mnemonic': mnemonic,
   'PrivateKey': u8aToHex(mnemonicToMiniSecret(mnemonic)),
   'PublicKey': u8aToHex(keyPair.publicKey),
   'SS58Address': keyPair.address
 };
 console.log(JSON.stringify(key, null, 2));
}
(async () => {
   await generateAccount()
})()
package.json
{
   "dependencies": {
       "@polkadot/api": "^3.6.4",
       "@polkadot/keyring": "^5.0.1",
       "@polkadot/util": "5.0.1",
       "@polkadot/util-crypto": "5.0.1"
   }
}
To test the script run  npm install  from the same location as your package.json file. You can then execute the script by running  node index.js
Example output
{
 "Mnemonic": "barrel doctor exercise age pelican close hard tower group property front copper",
 "PrivateKey": "0x2217fe2f9dacefa20026f3a9a049e2b774e06d0b2fd949e8cf728f224245bf0f",
 "PublicKey": "0x28bb4853c402de336e7a4e2d0eadb07644f706c511e372839669792318ad7d7b",
 "SS58Address": "5Cz7QZfu2Qxw3Cm5AdGGDgQWUuj5o3hbccQM4znneq73zmD2"
}
Updated by Olivier Bitsch over 3 years ago · 2 revisions