Skip to content

Commit 33ecdb4

Browse files
committed
reset index.js
1 parent 7f1f671 commit 33ecdb4

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

index.js

-61
Original file line numberDiff line numberDiff line change
@@ -1,61 +0,0 @@
1-
const { Api } = require('@cennznet/api');
2-
3-
const fs = require('fs');
4-
const { exit } = require('process');
5-
const createKeypair = require('./util/createKeypair');
6-
// A websocket address for some CENNZnet full nodes
7-
const NIKAU_WS = 'wss://nikau.centrality.me/public/ws';
8-
9-
// Peter address
10-
const PETER = '5GWVMKzwKVhdUXAv9dgTUZ4XUxXXTixgFZHnvKHRfwK93Hdn';
11-
12-
// Asset Id for CENNZ in Nikau
13-
const CENNZ = 16000;
14-
15-
16-
17-
async function sayHello(message, keyPairPath, password, amount) {
18-
// Setup a keyring to sign messages
19-
let myKeyPair = createKeypair(keyPairPath, password);
20-
21-
// Connect to Nikau network full nodes
22-
let api = await Api.create({ provider: NIKAU_WS });
23-
console.log(`Connecting to CENNZnet...`);
24-
25-
// Say hello, signing the message without keypair
26-
console.log(`Saying hello...\n\n`);
27-
28-
let txHash = (await api.tx.system.remark(message).signAndSend(myKeyPair));
29-
const transfer = api.tx.genericAsset.transfer(CENNZ, PETER, amount);
30-
const transfer_hash = await transfer.signAndSend(myKeyPair);
31-
32-
return [message, txHash, transfer_hash];
33-
}
34-
35-
const [message, keyPairPath, password, amount] = process.argv.slice(2);
36-
if(!message) {
37-
console.error('please provide a message');
38-
exit(1);
39-
}
40-
if(!keyPairPath) {
41-
console.error('please provide the key pair path');
42-
exit(1);
43-
}
44-
if(!password) {
45-
console.error('please provide a password');
46-
exit(1);
47-
}
48-
if(!amount) {
49-
console.error('please provide a amount');
50-
exit(1);
51-
}
52-
53-
sayHello(message, keyPairPath, password, amount)
54-
.then(([message, txHash]) => {
55-
console.log(`Said hello 🚀: '${message}'\nTx Hash: ${txHash}`)
56-
exit(0);
57-
})
58-
.catch((err) => {
59-
console.log(`Couldn\'t say hello because: ${err}`)
60-
exit(1)
61-
});

0 commit comments

Comments
 (0)