-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.js
82 lines (71 loc) · 2.06 KB
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*jslint node: true */
'use strict';
const path = require('path');
require('dotenv').config({ path: path.dirname(process.mainModule.paths[0]) + '/.env' });
const { getSigner } = require("./evm-chain.js");
const { transferEVM2Obyte, getTransfer, estimateOutput, csEvents } = require("counterstake-sdk");
async function estimate() {
const src_network = 'Ethereum';
const output_amount = await estimateOutput({
amount: 0.001,
src_network,
src_asset: 'ETH',
dst_network: 'Obyte',
dst_asset: 'OETHV2',
assistant_reward_percent: process.env.assistant_reward_percent || 1.00,
testnet: process.env.testnet,
});
console.log({ output_amount });
process.exit();
}
async function sendTransfer() {
const src_network = 'Ethereum';
const signer = getSigner(src_network);
const txid = await transferEVM2Obyte({
amount: 0.1,
src_network,
src_asset: 'USDC',
dst_network: 'Obyte',
dst_asset: 'OUSD_V2',
recipient_address: 'EJC4A7WQGHEZEKW6RLO7F26SAR4LAQBU',
assistant_reward_percent: process.env.assistant_reward_percent || 1.00,
signer,
testnet: process.env.testnet,
});
console.log({ txid });
// process.exit();
}
async function sendTransferWithData() {
const src_network = 'Ethereum';
const signer = getSigner(src_network);
const txid = await transferEVM2Obyte({
amount: 0.1,
src_network,
src_asset: 'USDC',
dst_network: 'Obyte',
dst_asset: 'OUSD_V2',
data: [7, 'nn', { ss: 'f-', a: 8 }],
recipient_address: 'EJC4A7WQGHEZEKW6RLO7F26SAR4LAQBU',
assistant_reward_percent: process.env.assistant_reward_percent || 1.00,
signer,
testnet: process.env.testnet,
});
console.log({ txid });
// process.exit();
}
async function checkTransfer() {
const transfer = await getTransfer('0xe35476b263bbdb488851dc3215d06297b31b08bc8c994778c72c46de60f16923', true);
console.log(transfer);
process.exit();
}
csEvents.on('NewClaim', claim => {
console.log('new claim', claim);
});
sendTransfer();
//sendTransferWithData();
//checkTransfer();
//estimate();
process.on('unhandledRejection', up => {
console.error('unhandledRejection event', up);
throw up;
});