Skip to content

Instantly share code, notes, and snippets.

@taoblockchain
Created September 16, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taoblockchain/6602bb067a82b27e6111ff133c3d8beb to your computer and use it in GitHub Desktop.
Save taoblockchain/6602bb067a82b27e6111ff133c3d8beb to your computer and use it in GitHub Desktop.
Tao Staking Script
/*
* RPC: https://rpc.tao.network mainnet, https://rpc.testnet.tao.network testnet
* chainId: 558 mainnet, 559 testnet
* Owner address: balance at least 100000 TOMO
* Coinbase is node address. You can create a empty wallet with https://wallet.testnet.tao.network
*/
const rpc = 'https://rpc.testnet.tao.network'
chainId = 559
const pkey = '[OWNER_PKEY]' // include 0x
const coinbase = "[YOUR_COINBASE_ADDRESS]"
const Web3 = require('web3');
const web3 = new Web3(rpc);
const account = web3.eth.accounts.privateKeyToAccount(pkey)
const owner = account.address
web3.eth.accounts.wallet.add(account)
web3.eth.defaultAccount = owner
// https://raw.githubusercontent.com/Tao-Network/shifu/master/abis/TomoValidatorAbi.json
const validatorAbi = require('./TaoValidatorAbi.json')
const address = '0x0000000000000000000000000000000000000088'
const validator = new web3.eth.Contract(validatorAbi,
address, {gasPrice: 250000000, gas: 2000000 })
validator.methods.propose(coinbase).send({
from: owner,
value: '100000000000000000000000', // 100K TAO
gas: 2000000,
gasPrice: 250000000,
chainId: chainId
})
.then((result) => {
console.log('Propose a new node', result)
// stake 500 TAO to node
return validator.methods.vote(coinbase).send({
from: owner,
value: '500000000000000000000', // 500 TAO
gas: 2000000,
gasPrice: 250000000,
chainId: chainId
})
.then((result) => {
console.log('Stake to a node', result)
}).catch(e => console.log(e))
}).catch(e => console.log(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment