Questions tagged [web3.py]

Web3.py helps you access your Ethereum node from Python. It is web3.js for Python.

The web3.py code is on github, and the docs are on readthedocs. To use web3.py, you must connect to a running, synced node.

957 questions
6
votes
3 answers

Web3 python - calling public variables

I have a contract that creates other contracts. It then pushes these contracts in an array, address[] public newContracts. The only problem is I'm having trouble calling them from python. factory.json is my abi and the address and web3 seem to…
thefett
  • 3,873
  • 5
  • 26
  • 48
6
votes
4 answers

How do I call functions from 'Read as proxy' on smart contracts?

Normally I just do this on python: token = web3.eth.contract(address=contract_address, abi=abi) balance_in_wei = token.functions.balanceOf(wallet).call() However, when the function isn't in the "Read Contract" tab, this code wouldn't work at…
Austin
  • 143
  • 3
  • 12
5
votes
2 answers

How can I convert from Gwei to Wei or Ether using web3py

I know there is web3.fromWei('myamount','ether') to convert from Wei to Ether. But what if I have only the Gwei amount?
Giuseppe
  • 185
  • 1
  • 2
  • 9
5
votes
1 answer

How to read solidity events and arguments from web3.py?

I am trying to create a python filter to read events from Smart contract but I am not successful so far. below is the sample python code and I have used "Instructor" event in solidity and trying to define "my_callback" function below whenever…
Arun Kuduva
  • 51
  • 1
  • 3
5
votes
3 answers

Signing A Raw transaction on contract function

I'm having some trouble signing a transaction on a contract function. First I build the transaction: transaction = contract_instance.functions.buy().buildTransaction( { 'nonce':…
Dorian Lee
  • 112
  • 1
  • 8
4
votes
2 answers

ValueError: {'code': -32000, 'message': 'already known'}

I am performing a transaction to send an ERC20 and I keep getting this error: ValueError: {'code': -32000, 'message': 'already known'} I'm assuming this means that this transaction is already in the mempool or something? Looking for some…
Patrick Collins
  • 11,186
  • 5
  • 44
  • 97
4
votes
2 answers

Failed building wheel error when installing web3 using pip and Python 3.8.2

I have been trying to install web3 using the command pip install web3 but it doesn't work !!!, I have tried so many solutions but nothing works , here is the error that I have, I hope guys you can help me. at the bigging, it gives this and then…
4
votes
2 answers

How to use a contract address to find block/transaction hashes of block where contract was deployed using web3.py

I am new to the Ethereum blockchain and web3.py, and I'm interested in finding a way to work with a contract address to return the block and transaction hashes for the block where the contract was deployed. I've been working with the getCode()…
BryantV90
  • 41
  • 3
4
votes
2 answers

How to create test accounts with custom balance programatically in web3.py?

I am trying to write tests for a smart contract and am having trouble transferring funds to the contract's address. I'm using web3.py app which (if I understand correctly) runs its own TestRPC, like this: w3 = Web3(TestRPCProvider()) Then I deploy…
johndodo
  • 511
  • 3
  • 15
3
votes
1 answer

Can I use the data returned by web3.eth.getTransaction() to determine if the transaction created a smart contract?

I am attempting to create a smart contract counter. Can I use the data returned by web3.eth.getTransaction() to determine if the transaction created a smart contract?
Julian Martinez
  • 409
  • 5
  • 14
3
votes
1 answer

ValueError: {'code': -32000, 'message': 'invalid sender'}

I'm trying to transfer some test ether from one Metamask address to another using the private key that I exported from it. But it always return a error code of -32000 with a message of 'Invalid sender'. import web3 import json from eth_account…
Henouji Kun
  • 33
  • 1
  • 3
3
votes
2 answers

How to deploy a contract on Infura with Web3.py v4

I am trying to deploy a contract to a test network like Ropsten. I am running through Infura using the HTTPProvider. I need to be able to sign the deployment of the contract locally, but can not figure out how to do this with the current API. Any…
Daniel Kurka
  • 131
  • 2
3
votes
2 answers

How to get transaction details from filter in web3.py

I am developing a software that listens for pending transactions. ... web3 = Web3(HTTPProvider(cfg.eth_node_url)) web3_pending_filter = web3.eth.filter('pending') transaction_list = web3.eth.getFilterChanges(web3_filter.filter_id) ... In…
Rafael Bogaveev
  • 179
  • 1
  • 2
  • 12
2
votes
0 answers

Slow transactions with Web3.py

In my python code I try to send multiples transactions from different address at the same time. The code build a transaction, sign it and send it, then I print "transaction number n sent" and it continue with the next one. It takes approximately 1…
Kioup
  • 125
  • 3
  • 10
2
votes
3 answers

web3.py - AttributeError: 'Eth' object has no attribute 'get_block'

So... I'm probably being super dumb - but I started using web3.py in a jupyter notebook and it connects to the node just fine... but I can't seem to use any .eth methods as it throws a: AttributeError: 'Eth' object has no attribute…
Lanski
  • 31
  • 1
  • 4
1
2 3 4 5 6