-
Notifications
You must be signed in to change notification settings - Fork 0
/
transfer.js
42 lines (37 loc) · 925 Bytes
/
transfer.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
// 转账
// 在 keys.json 文件里放入你的私钥
const eos = require('./eosClient.js');
const api = eos.api;
const from = 'fromaccount';
const to = 'toaccount';
const quant = 0.0001;
const memo = '';
const contract = 'eosio.token';
const symbol = 'EOS';
async function transfer(fromAccount, toAccount, quant, memo, tokenContract){
const resp = await api.transact({
actions: [{
account: tokenContract,
name: 'transfer',
authorization: [{
actor: fromAccount,
permission: 'active',
}],
data: {
from: fromAccount,
to: toAccount,
quantity: quant.toFixed(4) + ' ' + symbol,
memo: memo,
},
}]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
return resp;
}
transfer(from, to, quant, memo, contract).then((resp)=>{
console.log(resp);
}).catch((err)=>{
console.log(err);
});