blockDeployed field to store block number when the contract was deployed is implemented

This commit is contained in:
Alexander Kolotov 2018-02-27 23:45:03 +03:00
parent 2848036715
commit fb6dd85150
1 changed files with 38 additions and 0 deletions

View File

@ -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)