Aventus testnet testing » History » Version 1
Olivier Bitsch, 02/02/2022 10:02 AM
| 1 | 1 | Olivier Bitsch | # Aventus testnet testing |
|---|---|---|---|
| 2 | |||
| 3 | ## AvN gateway details |
||
| 4 | |||
| 5 | * Gateway URL: testnet.gateway.aventus.io |
||
| 6 | * Relayer Public key: 0x7075f2ec5abe24801ce8ccb2e7ffb13284df44c7baa9a583f8fd2f0498edb547 |
||
| 7 | * Relayer Address: 5EcAFwVcBo8s2D3ZSTnx2sq49wVDF3rc1yGJMx5nRp2GsK62 |
||
| 8 | |||
| 9 | ## AvN account generation |
||
| 10 | |||
| 11 | There are multiple ways of generating accounts to interact with the AvN blockchain. This document will highlight 2 of them. |
||
| 12 | |||
| 13 | Polkadot libraries can be used to generate accounts that are compatible with the AvN. The following example code demonstrates this. |
||
| 14 | index.js |
||
| 15 | |||
| 16 | ~~~ |
||
| 17 | const { Keyring } = require('@polkadot/keyring'); |
||
| 18 | const { u8aToHex } = require('@polkadot/util'); |
||
| 19 | const { cryptoWaitReady, mnemonicGenerate, mnemonicToMiniSecret } = require('@polkadot/util-crypto'); |
||
| 20 | |||
| 21 | async function generateAccount(accountCrypto) { |
||
| 22 | let crypto = accountCrypto || 'sr25519'; |
||
| 23 | |||
| 24 | if (!['ed25519', 'sr25519'].includes(crypto)) { |
||
| 25 | throw (`Invalid account crypto "${crypto}" specified.`); |
||
| 26 | } |
||
| 27 | |||
| 28 | await cryptoWaitReady(); |
||
| 29 | |||
| 30 | const keyring = new Keyring({ type: crypto, ss58Format: 42 }); |
||
| 31 | const mnemonic = mnemonicGenerate(); |
||
| 32 | const keyPair = keyring.createFromUri(mnemonic); |
||
| 33 | |||
| 34 | const key = { |
||
| 35 | 'Mnemonic': mnemonic, |
||
| 36 | 'PrivateKey': u8aToHex(mnemonicToMiniSecret(mnemonic)), |
||
| 37 | 'PublicKey': u8aToHex(keyPair.publicKey), |
||
| 38 | 'SS58Address': keyPair.address |
||
| 39 | }; |
||
| 40 | |||
| 41 | console.log(JSON.stringify(key, null, 2)); |
||
| 42 | } |
||
| 43 | |||
| 44 | (async () => { |
||
| 45 | await generateAccount() |
||
| 46 | })() |
||
| 47 | |||
| 48 | package.json |
||
| 49 | { |
||
| 50 | "dependencies": { |
||
| 51 | "@polkadot/api": "^3.6.4", |
||
| 52 | "@polkadot/keyring": "^5.0.1", |
||
| 53 | "@polkadot/util": "5.0.1", |
||
| 54 | "@polkadot/util-crypto": "5.0.1" |
||
| 55 | } |
||
| 56 | } |
||
| 57 | ~~~ |
||
| 58 | |||
| 59 | 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 |
||
| 60 | Example output |
||
| 61 | ~~~ |
||
| 62 | { |
||
| 63 | "Mnemonic": "barrel doctor exercise age pelican close hard tower group property front copper", |
||
| 64 | "PrivateKey": "0x2217fe2f9dacefa20026f3a9a049e2b774e06d0b2fd949e8cf728f224245bf0f", |
||
| 65 | "PublicKey": "0x28bb4853c402de336e7a4e2d0eadb07644f706c511e372839669792318ad7d7b", |
||
| 66 | "SS58Address": "5Cz7QZfu2Qxw3Cm5AdGGDgQWUuj5o3hbccQM4znneq73zmD2" |
||
| 67 | } |
||
| 68 | ~~~ |