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