Test services update. New script for side prefund
This commit is contained in:
parent
9cdadc27b2
commit
d4f4591616
|
@ -4,6 +4,9 @@ set -e
|
||||||
|
|
||||||
cd $(dirname "$0")
|
cd $(dirname "$0")
|
||||||
|
|
||||||
|
# either development or staging
|
||||||
|
TARGET_NETWORK=${TARGET_NETWORK:=development}
|
||||||
|
|
||||||
docker build -t binance-balance . > /dev/null
|
docker build -t binance-balance . > /dev/null
|
||||||
|
|
||||||
docker run --rm --env-file .env binance-balance $@
|
docker run --rm --env-file ".env.$TARGET_NETWORK" binance-balance $@
|
||||||
|
|
|
@ -4,6 +4,9 @@ set -e
|
||||||
|
|
||||||
cd $(dirname "$0")
|
cd $(dirname "$0")
|
||||||
|
|
||||||
|
# either development or staging
|
||||||
|
TARGET_NETWORK=${TARGET_NETWORK:=development}
|
||||||
|
|
||||||
docker build -t binance-send . > /dev/null
|
docker build -t binance-send . > /dev/null
|
||||||
|
|
||||||
docker run --rm --env-file .env binance-send $@
|
docker run --rm --env-file ".env.$TARGET_NETWORK" --env-file "../keys.$TARGET_NETWORK" binance-send $@
|
||||||
|
|
|
@ -4,6 +4,9 @@ set -e
|
||||||
|
|
||||||
cd $(dirname "$0")
|
cd $(dirname "$0")
|
||||||
|
|
||||||
|
# either development or staging
|
||||||
|
TARGET_NETWORK=${TARGET_NETWORK:=development}
|
||||||
|
|
||||||
docker build -t ethreum-balance . > /dev/null
|
docker build -t ethreum-balance . > /dev/null
|
||||||
|
|
||||||
docker run --network blockchain_home --rm --env-file .env ethreum-balance $@
|
docker run --network blockchain_home --rm --env-file ".env.$TARGET_NETWORK" ethreum-balance $@
|
||||||
|
|
|
@ -9,6 +9,8 @@ const token = new web3.eth.Contract(abiToken, HOME_TOKEN_ADDRESS)
|
||||||
|
|
||||||
const address = process.argv[2]
|
const address = process.argv[2]
|
||||||
|
|
||||||
|
web3.eth.getBalance(address).then(x => console.log(x.toString()))
|
||||||
|
|
||||||
token.methods.balanceOf(address).call()
|
token.methods.balanceOf(address).call()
|
||||||
.then(x => console.log(x.toString()))
|
.then(x => console.log(x.toString()))
|
||||||
.catch(() => console.log(0))
|
.catch(() => console.log(0))
|
||||||
|
|
|
@ -4,6 +4,9 @@ set -e
|
||||||
|
|
||||||
cd $(dirname "$0")
|
cd $(dirname "$0")
|
||||||
|
|
||||||
|
# either development or staging
|
||||||
|
TARGET_NETWORK=${TARGET_NETWORK:=development}
|
||||||
|
|
||||||
docker build -t ethreum-send . > /dev/null
|
docker build -t ethreum-send . > /dev/null
|
||||||
|
|
||||||
docker run --network blockchain_home --rm --env-file .env ethreum-send $@
|
docker run --network blockchain_home --rm --env-file ".env.$TARGET_NETWORK" --env-file "../keys.$TARGET_NETWORK" ethreum-send $@
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const BN = require('bignumber.js')
|
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, HOME_BRIDGE_ADDRESS, HOME_PRIVATE_KEY, HOME_TOKEN_ADDRESS } = process.env
|
||||||
|
|
||||||
const abiToken = require('./IERC20').abi
|
const abiToken = require('./IERC20').abi
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ const token = new web3.eth.Contract(abiToken, HOME_TOKEN_ADDRESS)
|
||||||
const sender = web3.eth.accounts.privateKeyToAccount(`0x${HOME_PRIVATE_KEY}`).address
|
const sender = web3.eth.accounts.privateKeyToAccount(`0x${HOME_PRIVATE_KEY}`).address
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
|
const HOME_CHAIN_ID = await web3.eth.net.getId()
|
||||||
|
|
||||||
let to = process.argv[2]
|
let to = process.argv[2]
|
||||||
|
|
||||||
|
@ -49,13 +50,13 @@ async function main () {
|
||||||
from: sender,
|
from: sender,
|
||||||
to: to,
|
to: to,
|
||||||
nonce: await web3.eth.getTransactionCount(sender),
|
nonce: await web3.eth.getTransactionCount(sender),
|
||||||
chainId: parseInt(HOME_CHAIN_ID),
|
chainId: HOME_CHAIN_ID,
|
||||||
value: web3.utils.toWei(new BN(coins).toString(), 'ether'),
|
value: web3.utils.toWei(new BN(coins).toString(), 'ether'),
|
||||||
gas: 21000
|
gas: 21000
|
||||||
}
|
}
|
||||||
signedTx = await web3.eth.accounts.signTransaction(tx_coins, HOME_PRIVATE_KEY)
|
const signedTx = await web3.eth.accounts.signTransaction(tx_coins, HOME_PRIVATE_KEY)
|
||||||
|
|
||||||
receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction)
|
const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction)
|
||||||
console.log('txHash: ' + receipt.transactionHash)
|
console.log('txHash: ' + receipt.transactionHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
FROM node:10.16.0-alpine
|
||||||
|
|
||||||
|
WORKDIR /test
|
||||||
|
|
||||||
|
COPY package.json /test/
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY testEthereumSend.js /test/
|
||||||
|
|
||||||
|
ENTRYPOINT ["node", "testEthereumSend.js"]
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "ethereum-send",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"dependencies": {
|
||||||
|
"bignumber.js": "9.0.0",
|
||||||
|
"web3": "1.0.0-beta.55"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd $(dirname "$0")
|
||||||
|
|
||||||
|
echo "Using $TARGET_NETWORK network"
|
||||||
|
|
||||||
|
docker build -t ethereum-send . > /dev/null
|
||||||
|
|
||||||
|
docker run --network blockchain_side --rm --env-file .env --env-file "../.env.$TARGET_NETWORK" ethereum-send $@
|
|
@ -0,0 +1,34 @@
|
||||||
|
const Web3 = require('web3')
|
||||||
|
const BN = require('bignumber.js')
|
||||||
|
|
||||||
|
const { SIDE_RPC_URL, SIDE_PRIVATE_KEY } = process.env
|
||||||
|
|
||||||
|
const web3 = new Web3(SIDE_RPC_URL, null, { transactionConfirmationBlocks: 1 })
|
||||||
|
|
||||||
|
const sender = web3.eth.accounts.privateKeyToAccount(`0x${SIDE_PRIVATE_KEY}`).address
|
||||||
|
|
||||||
|
async function main () {
|
||||||
|
const SIDE_CHAIN_ID = await web3.eth.net.getId()
|
||||||
|
|
||||||
|
const to = process.argv[2]
|
||||||
|
const amount = parseFloat(process.argv[3])
|
||||||
|
|
||||||
|
console.log(`Transfer from ${sender} to ${to}, ${amount} eth`)
|
||||||
|
|
||||||
|
const tx_coins = {
|
||||||
|
data: '0x',
|
||||||
|
from: sender,
|
||||||
|
to: to,
|
||||||
|
nonce: await web3.eth.getTransactionCount(sender),
|
||||||
|
chainId: SIDE_CHAIN_ID,
|
||||||
|
value: web3.utils.toWei(new BN(amount).toString(), 'ether'),
|
||||||
|
gas: 21000
|
||||||
|
}
|
||||||
|
const signedTx = await web3.eth.accounts.signTransaction(tx_coins, SIDE_PRIVATE_KEY)
|
||||||
|
|
||||||
|
const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction)
|
||||||
|
console.log('txHash: ' + receipt.transactionHash)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
Loading…
Reference in New Issue