specify sender rather than bridge contracts, proper sending of erc20 tokens
This commit is contained in:
parent
16ebb69b33
commit
1d9939cef5
|
@ -1,6 +1,8 @@
|
|||
HOME_RPC_URL=http://ganache_home:8545
|
||||
HOME_BRIDGE_ADDRESS=0x94b40CC641Ed7db241A1f04C8896ba6f6cC36b85
|
||||
RECEIVER_ADDRESS=0x94b40CC641Ed7db241A1f04C8896ba6f6cC36b85
|
||||
|
||||
HOME_CHAIN_ID=44
|
||||
HOME_TOKEN_ADDRESS=0x44c158FE850821ae69DaF37AADF5c539e9d0025B
|
||||
|
||||
HOME_PRIVATE_KEY=e2aeb24eaa63102d0c0821717c3b6384abdabd7af2ad4ec8e650dce300798b27
|
||||
HOME_PRIVATE_KEY=e2aeb24eaa63102d0c0821717c3b6384abdabd7af2ad4ec8e650dce300798b27
|
|
@ -2,6 +2,7 @@
|
|||
"name": "ethereum-send",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"bignumber.js": "9.0.0",
|
||||
"web3": "1.0.0-beta.55"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const Web3 = require('web3')
|
||||
const BN = require('bignumber.js')
|
||||
|
||||
const { HOME_RPC_URL, HOME_BRIDGE_ADDRESS, HOME_CHAIN_ID, HOME_PRIVATE_KEY, HOME_TOKEN_ADDRESS } = process.env
|
||||
const { HOME_RPC_URL, RECEIVER_ADDRESS, HOME_CHAIN_ID, HOME_PRIVATE_KEY, HOME_TOKEN_ADDRESS } = process.env
|
||||
|
||||
const abiToken = require('./IERC20').abi
|
||||
|
||||
|
@ -9,18 +10,18 @@ const token = new web3.eth.Contract(abiToken, HOME_TOKEN_ADDRESS)
|
|||
|
||||
const amount = parseInt(process.argv[2])
|
||||
|
||||
const deployAddress = web3.eth.accounts.privateKeyToAccount(`0x${HOME_PRIVATE_KEY}`).address
|
||||
const sender = web3.eth.accounts.privateKeyToAccount(`0x${HOME_PRIVATE_KEY}`).address
|
||||
|
||||
async function main () {
|
||||
console.log(`Transfer from ${deployAddress} to ${HOME_BRIDGE_ADDRESS}, ${amount} tokens`)
|
||||
console.log(`Transfer from ${sender} to ${RECEIVER_ADDRESS}, ${amount} tokens`)
|
||||
|
||||
const query = token.methods.transfer(HOME_BRIDGE_ADDRESS, amount)
|
||||
const query = token.methods.transfer(RECEIVER_ADDRESS, '0x'+(new BN(amount).toString(16)))
|
||||
const encodedABI = query.encodeABI()
|
||||
const tx = {
|
||||
data: encodedABI,
|
||||
from: deployAddress,
|
||||
from: sender,
|
||||
to: HOME_TOKEN_ADDRESS,
|
||||
nonce: await web3.eth.getTransactionCount(deployAddress),
|
||||
nonce: await web3.eth.getTransactionCount(sender),
|
||||
chainId: parseInt(HOME_CHAIN_ID)
|
||||
}
|
||||
tx.gas = Math.min(Math.ceil(await query.estimateGas(tx) * 1.5), 6721975)
|
||||
|
|
Loading…
Reference in New Issue