-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgovernance_aepp_delegate_voting_power.js
More file actions
46 lines (41 loc) · 1.39 KB
/
governance_aepp_delegate_voting_power.js
File metadata and controls
46 lines (41 loc) · 1.39 KB
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
const { AeSdk, MemoryAccount, Node, getAddressFromPriv } = require('@aeternity/aepp-sdk')
const CONTRACT_ACI = require('./aci/GovernanceRegistryACI.json')
const shutdown = (varName) => {
console.error(`Missing ENV variable: ${varName}`)
process.exit(1)
}
if(!process.env.SECRET_KEY) {
shutdown('SECRET_KEY')
}
if(!process.env.DELEGATEE) {
shutdown('DELEGATEE')
}
const KEYPAIR = {
secretKey: process.env.SECRET_KEY,
publicKey: getAddressFromPriv(process.env.SECRET_KEY)
}
const DELEGATEE = process.env.DELEGATEE
const AE_NETWORK = process.env.AE_NETWORK || 'TESTNET'
const SETTINGS = {
TESTNET: {
nodeUrl: 'https://testnet.aeternity.io',
contractAddress: 'ct_2nritSnqW6zooEL4g2SMW5pf12GUbrNyZ17osTLrap7wXiSSjf',
},
MAINNET: {
nodeUrl: 'https://mainnet.aeternity.io',
contractAddress: 'ct_ouZib4wT9cNwgRA1pxgA63XEUd8eQRrG8PcePDEYogBc1VYTq',
}
}
const main = async () => {
const node = new Node(SETTINGS[AE_NETWORK].nodeUrl)
const aeSdk = new AeSdk({
nodes: [
{ name: AE_NETWORK, instance: node },
],
accounts: [MemoryAccount({ keypair: KEYPAIR })],
})
const contractInstance = await aeSdk.getContractInstance({ aci: CONTRACT_ACI, contractAddress: SETTINGS[AE_NETWORK].contractAddress })
const delegateTx = await contractInstance.methods.delegate(DELEGATEE)
console.log(delegateTx)
}
main()