Skip to content

Instantly share code, notes, and snippets.

@thanhson1085
Last active September 22, 2022 13:25
Show Gist options
  • Save thanhson1085/3c831416287b0c1f4afbf9fcb3aa05dc to your computer and use it in GitHub Desktop.
Save thanhson1085/3c831416287b0c1f4afbf9fcb3aa05dc to your computer and use it in GitHub Desktop.
/*
* RPC: https://rpc.tomochain.com mainnet, https://rpc.testnet.tomochain.com testnet
* chainId: 88 mainnet, 89 testnet
*/
const Web3 = require('web3')
const rpc = 'https://rpc.testnet.tomochain.com'
const chainId = 89
const pkey = 'YOUR_PKEY' // token holder pkey
const contractAddress = 'TOKEN_CONTRACT_ADDRESS' // token contract address
const web3 = new Web3(rpc)
const account = web3.eth.accounts.privateKeyToAccount(pkey)
const holder = account.address
web3.eth.accounts.wallet.add(account)
web3.eth.defaultAccount = holder
const trc20Abi = require('./TRC20.json')
const trc20 = new web3.eth.Contract(trc20Abi,
contractAddress, {gasPrice: 250000000, gas: 2000000 })
// check token balance
trc20.methods.balanceOf(holder).call()
.then((result) => {
console.log(result)
}).catch(e => console.log(e))
const to = '0xf8ac9d5022853c5847ef75aea0104eed09e5f402' // e.g send tokens to this address
// Estimate fee for sending tokens
trc20.methods.transfer(to, '500000000000000000000').estimateGas({
from: holder
})
.then((result) => {
console.log(result)
}).catch(e => console.log(e))
// trasfer token to new address, make sure you have enough TOMO to pay tx fee
trc20.methods.transfer(to, '500000000000000000000').send({
from: holder,
gas: 2000000,
gasPrice: 250000000,
chainId: chainId
})
.then((result) => {
console.log(result)
}).catch(e => console.log(e))
@YUVRAJABNISH
Copy link

How to deploy this code and what is bot code for this json

@atcoolart
Copy link

@pubgking71599
Copy link

Dm me @ABHISHEK71599 on telegram to make bots

@aliqasemzadeh
Copy link

aliqasemzadeh commented Sep 22, 2022

Hi
Is there any main net free RPC Server?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment