1
web3 = Web3(provider=HTTPProvider(http://ropsten.infura.io/v4/API_KEY)
abi = '[{"constant":false,"inputs":[{"name":"_utxoPos","type":"uint256"},{"name":"_txBytes","type":"bytes"},{"name":"_proof","type":"bytes"},{"name":"_sigs","type":"bytes"}],"name":"startExit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_cUtxoPos","type":"uint256"},{"name":"_eUtxoIndex","type":"uint256"},{"name":"_txBytes","type":"bytes"},{"name":"_proof","type":"bytes"},{"name":"_sigs","type":"bytes"},{"name":"_confirmationSig","type":"bytes"}],"name":"challengeExit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"exits","outputs":[{"name":"owner","type":"address"},{"name":"token","type":"address"},{"name":"amount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_amount","type":"uint256"}],"name":"startFeeExit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"srcTokenAddress","type":"address"},{"name":"destTokenAddress","type":"address"},{"name":"sendToUserAddresss","type":"address"},{"name":"maxDestAmount","type":"uint256"},{"name":"minConversionRate","type":"uint256"}],"name":"depositKyberTokens","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"operator","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentChildBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"finalizeExits","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_blockNumber","type":"uint256"}],"name":"getChildChain","outputs":[{"name":"","type":"bytes32"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_token","type":"address"}],"name":"getNextExit","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"CHILD_BLOCK_INTERVAL","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentDepositBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_root","type":"bytes32"}],"name":"submitBlock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getDepositBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentFeeExit","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"exitsQueues","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_utxoPos","type":"uint256"}],"name":"getExit","outputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_depositPos","type":"uint256"},{"name":"_token","type":"address"},{"name":"_amount","type":"uint256"}],"name":"startDepositExit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"childChain","outputs":[{"name":"root","type":"bytes32"},{"name":"timestamp","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"depositor","type":"address"},{"indexed":true,"name":"depositBlock","type":"uint256"},{"indexed":false,"name":"token","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"exitor","type":"address"},{"indexed":true,"name":"utxoPos","type":"uint256"},{"indexed":false,"name":"token","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"ExitStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"root","type":"bytes32"},{"indexed":false,"name":"timestamp","type":"uint256"}],"name":"BlockSubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"token","type":"address"}],"name":"TokenAdded","type":"event"}]'
contract_instance = web3.eth.contract(address, abi=abi)
currentChild = contract_instance.CHILD_BLOCK_INTERVAL.call()

Trying to connect my smart contract in Python and access attributes deployed on Ropsten but getting error:

AttributeError: 'Contract' object has no attribute 'CHILD_BLOCK_INTERVAL'

  • just looking at your ABI, it looks it is a wrong one, there is no definition for CHILD_BLOCK_INTERVAL – Jaime Sep 3 '18 at 14:12
  • its a constant member variable of unsigned integer data type mentioned in ABI. Did you say it must be defined or initiated with some value in ABI too ? – faran ahmed Sep 4 '18 at 5:49
0

From the ABI's perspective, public attributes are just like functions, so you use the function call syntax, like:

contract_instance.functions.CHILD_BLOCK_INTERVAL.call()
  • requests.exceptions.ReadTimeout: HTTPConnectionPool(host='ropsten.infura.io', port=80): Read timed out. (read timeout=30) updated web3.py => 4.6.0 in Python changed timeout from 10s to 30s => provider=HTTPProvider('ropsten.infura.io/v4/API_KEY', request_kwargs={'timeout': 30}) but still same error following you while my smart contract – faran ahmed Sep 4 '18 at 6:18
  • Have you tried with another node besides Infura? Maybe a local geth or parity in light mode? – carver Sep 4 '18 at 16:24
  • found that I can get blocks, transactions on "geth attach localhost:8545". but i wanted to access blocks created only on deployed smart contract on ropsten. Is there any tutorial or helping material to follow and get blocks created. – faran ahmed Sep 5 '18 at 6:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.