From fb6dd85150dc76136cfb35178a72218998e83ccf Mon Sep 17 00:00:00 2001 From: Alexander Kolotov Date: Tue, 27 Feb 2018 23:45:03 +0300 Subject: [PATCH] blockDeployed field to store block number when the contract was deployed is implemented --- erc20/bridge/contracts/get_block_deployed.py | 38 ++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 erc20/bridge/contracts/get_block_deployed.py diff --git a/erc20/bridge/contracts/get_block_deployed.py b/erc20/bridge/contracts/get_block_deployed.py new file mode 100755 index 0000000..1238ee3 --- /dev/null +++ b/erc20/bridge/contracts/get_block_deployed.py @@ -0,0 +1,38 @@ +#!/opt/anaconda3/bin/python + +from web3 import Web3 +import json +from toml import load +import sys + +_contractName='ForeignBridge' +_abiFile=_contractName+".abi" + +bridge_config = load('/home/koal/parity/bridge/erc20.toml') +bridge_db = load('/home/koal/parity/bridge/erc20_db.toml') + +def getBlockNumber(_chain): + IPC_file = bridge_config[_chain]['ipc'] + web3 = Web3(Web3.IPCProvider(IPC_file)) + + bridgeContractAddress = web3.toChecksumAddress(bridge_db[_chain + '_contract_address']) + + #---------------------------------------------------------------------------- + # Read ABI + #---------------------------------------------------------------------------- + with open(_abiFile) as f: + _contractABI=json.load(f) + f.close() + + ContractFactory = web3.eth.contract( + abi = _contractABI, + ) + + BridgeContract = ContractFactory(bridgeContractAddress) + + print(_chain, "bridge contract deployed at:", BridgeContract.functions.blockDeployed().call()) + +getBlockNumber('home') +getBlockNumber('foreign') + +sys.exit(0)