Questions tagged [web3py]

Web3.py is a library for interacting with EVM based blockchains and smart contracts in Python.

For more information see Web3.py documentation.

Web3.py is maintained by Ethereum Foundation.

578 questions
3
votes
3 answers

How to get Solidity revert/require error reason in Python and web3.py

I am trying to catch require() errors when the transaction is reverted , but I get transaction's hash, I am using web3.py def addParticipants(request): web3 = Web3(HTTPProvider(settings.Blockchain_IP_address, request_kwargs={'timeout': 60})) …
Wael Golli
  • 87
  • 2
  • 8
3
votes
3 answers

How to get the specific token balance available at a give ETH address using web3.py

I am getting started with web.py. I have a requirement where I need to get the available token balance at a given ETH address(this address is not the contract owner), going through the docs I stumble upon the following functiion…
Paras
  • 3,191
  • 6
  • 41
  • 77
3
votes
1 answer

Transaction is never mined, using web3.py

I'm developing a website using python 3.6, Django 2.1.1, Solidity and web3.py v4. I want to add the transaction to ropsten testnet but the transactions are never getting confirmed. Here is the code: amount_in_wei =…
yasaman.h
  • 81
  • 8
3
votes
2 answers

Access private key after personal.newAccount in web3.py

I have created an Ethereum account using web3.py in python 3.6: web3.personal.newAccount('password') How do I access the private key for that account?
MUHASIN BABU
  • 313
  • 3
  • 9
3
votes
2 answers

Py-solc and solidity imports

How can I compile solidity files which perform relative imports through py-solc? Here's a minimal example: Directory structure my-project - main.py - bar.sol - baz.sol main.py: from solc import compile_source def…
Paymahn Moghadasian
  • 9,301
  • 13
  • 56
  • 94
3
votes
5 answers

How to fix web3 module AttributeError?

I am trying to using web3 in python. I am trying to follow the steps in http://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth import web3 web3.eth.getBlock("1028201") But got AttributeError: module 'web3.eth' has no attribute…
BlueDolphin
  • 9,765
  • 20
  • 59
  • 74
2
votes
0 answers

Fail with error 'hasFee'. web3.py, depositToken

I can't execute the transaction, I get the error 'Fail with error 'hasFee'' Code: client.py import logging import traceback from eth_account.signers.local import LocalAccount from web3 import Web3 from typing import Optional from web3.middleware…
Printon
  • 31
  • 2
2
votes
1 answer

What are the steps to use Python or Polygon SDK to create a Polygon blockchain account without using any wallet?

Can you provide a detailed guide on how to use Python to create a user account on the Polygon Proof-of-Stake (PoS) blockchain, including all necessary steps and explanations? Can you provide a step-by-step guide on how to create a user account on…
2
votes
1 answer

AttributeError: 'Eth' object has no attribute 'getTransactionCount'

I am trying to deploy this code to get the latest transaction and I get this error: Traceback (most recent call last): File "/home/elly/practice/web3/deploy.py", line 72, in nonce = w3.eth.getTransactionCount(my_address) AttributeError: 'Eth' object…
Elena 46
  • 23
  • 3
2
votes
1 answer

Sending multiple transactions as once

What are some ways to send multiple transactions at once to a ganache blockchain ? I am using the web3.py library.
2
votes
0 answers

web3py EthereumTesterProvider - Basic interactions with a smart contract fail

On the web3py EthereumTesterProvider blockchain, I tested the contract deployment example at https://web3py.readthedocs.io/en/v5/contracts.html. But I came across 2 errors. pip config (windows 10) : web3py (5.31.3) eth-tester (0.8.0b3) Here is the…
u2gilles
  • 6,888
  • 7
  • 51
  • 75
2
votes
2 answers

How to use .env files and environment variables with Python and macOS

So I am connecting to an RPC cloud-node and trying to get the latest block from the Ethereum blockchain, along with all the block details and have written some code in python using web3.py. I have the code ready and according to the official doc…
2
votes
2 answers

How to query blockchain for latest smart contract deployments with web3.py?

How would I get a list of addresses of the newest smart contracts deployed to the ethereum blockchain? I would like to use web3.py if possible or a free api solution. I need the contract address and the time of deployment in the returned results. If…
2
votes
1 answer

Can we get token name from web3.py by providing the contract address?

For example, can we get 'USDC' returned by providing its contract address 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48?
Warren
  • 991
  • 11
  • 28
2
votes
0 answers

MATIC + Web3 : Unable to interact with a deployed smart contract

I have deployed the simple datastorage example smart contract on mumbai testnet. I have the smart contract abi and address. I am trying to use web3 in my python code to interact with smart contract. But, I keep getting this error "ValueError:…
skr
  • 127
  • 2
  • 16