Project

General

Profile

Aventus testnet testing » History » Version 4

Olivier Bitsch, 02/09/2022 03:47 PM

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