-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
57 lines (50 loc) · 1.21 KB
/
deploy.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
// 部署合约
// 在 keys.json 文件里放入你的私钥
// 替换 xxxxxaccount 为合约账号
const account = 'xxxxxaccount';
var wasm = fs.readFileSync('contracts/eosio.token/eosio.token.wasm');
var abi = fs.readFileSync('contracts/eosio.token/eosio.token.abi');
// Publish contract to the blockchain
const eos = require('./eosClient.js');
const api = eos.api;
async function deploy(account, wasm, abi){
const resp = await api.transact({
actions: [{
account: 'eosio',
name: 'setcode',
authorization: [{
actor: account,
permission: 'active',
}],
data: {
account: account,
vmtype: 0,
vmversion: 0,
code: wasm
},
},
{
account: 'eosio',
name: 'setabi',
authorization: [{
actor: account,
permission: 'active',
}],
data: {
account: account,
abi: abi
},
}
]
}, {
blocksBehind: 3,
expireSeconds: 30,
});
return resp;
}
// wasm = new Uint8Array(); // to clear contract
deploy(account, wasm, JSON.parse(abi)).then((resp)=>{
console.log(resp);
}).catch((err)=>{
console.log(err);
});