We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [web3.py]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
29 views

Web3: can last block be replaced?

I'm using web3py's getBlock function to get the latest block. I am right now caching the latest 50 blocks so that I reduce the amount of workload in my geth node, and to improve overall speed in my ...
1
vote
0answers
19 views

pass struct from web3 python interface to solidity

I have created a smart contract with some solidity functions which take structs, enums and mappings(all defined in my contract) as arguments. I intend to call these functions from my web3 python ...
0
votes
1answer
13 views

Connect dApp hosted on cloud with Geth running locally

I've my dApp running on AWS and Geth running locally. How am I supposed to connect my hosted dApp with the Geth? I'm connecting my web3(using web3.py) using my computer's(Windows OS) IP address. ...
0
votes
1answer
15 views

Can I call a contract function in the “data” element via web3, especially when I am using conversion to bytes?

In other words, say In Python I have something like that: signed_txn = w3.eth.account.signTransaction(dict( nonce=w3.eth.getTransactionCount('0x0000000000000000000000000000000'), gasPrice = ...
0
votes
1answer
21 views

What's the difference between the typical ERC20 Transfer(from, to, value) and the same but with bytes, e.q.: Trasnfer(from, to, value, msg.data)?

Better question: Can I send the bytes to a function that lacks this definition? In other words, say I have: event Transfer(address,address,uint256, bytes); And then: function transfer(msg....
0
votes
1answer
14 views

AttributeError while trying to call a contract using web3py and Infura

I am trying to call a function from an already-deployed contract on the Ropsten network: from web3 import Web3 infura_url = "https://ropsten.infura.io/v3/XXXXXXXXXXXXXX" w3 = Web3(Web3.HTTPProvider(...
1
vote
1answer
17 views

Call Smart Contract Function in Python Script

My situation is reverse to most. I am relatively experienced in coding in Solidity, but have absolutely no experience in using Python. What I would ideally like to do is have a script that will, in ...
1
vote
1answer
28 views

Problems calling function with web3 from python

I was trying to call a function from my python server to a contract deployed in Ropsten. This is my method in the contract: function send(address receiver, uint amount) public { require(msg....
0
votes
1answer
25 views

Error sending ether to a a smart contract deployed in ropsten with web3 with python

I am trying to send ether to a smart contract deployed on ropsten via infura, but I am having some problems in txn. The error is "Error in Txn: Reverted". The sender account has enought ether to ...
1
vote
1answer
42 views

Web3js & Web3.py ERC20 Name, Symbol, & Decimals call(): Results in Web3.exceptions & OverflowError for Some But Not All Existing Contracts

I'm building simple Javascript & Python 3 scripts using the Web3 module to output ERC20 token names, symbols, and decimals from any given contract address. The standard ERC20_ABI json file was ...
2
votes
1answer
25 views

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?
1
vote
1answer
16 views

How do you inspect the properties and methods of a web3 object in web3.py?

How do you inspect the properties and methods of a web3 object in web3.py? In Node.js, if I type in the name of my web3 instance and press enter, the object is printed in the console. I am able to ...
0
votes
1answer
26 views

How can I implement redactable chain for ETH?

I am trying to research about Redactable blockchain so my question is how can I implement a Redactable chain in Eth if someone has some idea about it I will be thankful
0
votes
0answers
13 views

How to deploy contract using ropsten infural url and web3.py? [duplicate]

# web3.py instance >>> w3 = Web3(Web3.EthereumTesterProvider()) # set pre-funded account as sender >>> w3.eth.defaultAccount = w3.eth.accounts[0] # get bytecode >>> ...
0
votes
1answer
19 views

Using Metamask with Ropsten and Web3.py

I have used Ganache to compile and deploy my contract successfully. Now I would like to do the same on the Ropsten network using my Metamask account. I don't want the Metamask plugin to pop up every ...
0
votes
0answers
11 views

How to deploy smart contract with private wallet?

I am now deploying smart contract using ganache localhost:7545, i want to use infura ropsten account to deploy. Most examples uses Metamask, but i want use own ethreum wallet. How can i use to deploy? ...
1
vote
1answer
35 views

web3py - Function Call when Sender Must Be Certain Address

I have a contract on Ropsten, and when I do this is python, I get a result: result = contract.functions.getLastUpdateTime(0).call() So I know the ABI is there, the address, etc. There's another ...
0
votes
1answer
29 views

Adding a pending transaction to get the balance results in a different outcome

language : python 3.7 network : kovan use web3(infura) I want to check the balance as well as the pending transaction. The address below is the address with the Pending transaction. Testing in the ...
1
vote
3answers
70 views

How do I send a transaction using web3.py and Infura?

I am using Infura to interact with the Ropsten testnet. I would like to send a transaction from one account to another, but the following code does not work: w3 = Web3(Web3.HTTPProvider('InfuraUrl')) ...
0
votes
0answers
23 views

How to deploy contract instance in blockchain with abi and contract address?

I am following this (python ethereum interface tutorial) and contracts to compile and deploy in ganache cli. Till now i am able to compile and deploy contracts with web3.py,py-solc and ganache node. ...
0
votes
1answer
25 views

DDEX Api Question for Python… Signing ETH Transactions?

Having an issue with signing a message for the DDEX api... I'm trying to do it in python, and for some reason my signature is off by two characters. Here's my code using the private key and UTC ...
0
votes
0answers
16 views

web3py Filter Contract Events

I am new to web3py and I am trying to filter the events of a certain ERC20 contract. I can successfully call the contract's functions, but I struggle with the events. contract = w3.eth.contract(...
0
votes
1answer
46 views

TimeoutError when using Infura websocket with web3.py

When I run the following code sometimes it executes successfully, but most of the time it raises a concurrent.futures._base.TimeoutError. What can I do to fix this? Here is the code: infura_url_ws = ...
0
votes
0answers
31 views

How do i connect geth to web3.py using IPC on Windows?

I'll briefly explain my setup before describing the problem in detail. I am on Windows 10 and using the geth client in Light Sync Mode, along with web3.py on Jupyter Notebook and Metamask as a wallet....
0
votes
0answers
33 views

Sign Message using passphrase only

I'm creating an authentication system using python and web3.py. I'm trying to authenticate a user using from web3.auto import w3 msg = 'sdb41554xcb4xc548cxd84dxcb' message = encode_defunct(text=...
0
votes
1answer
52 views

While importing web3.py getting following error: TypeError: 'ellipsis' object is not iterable [closed]

Python version : 3.5.2. web3 version : 4.9.2. Ubuntu : 16.04. Also tried previous version of web3: 4.0.0
0
votes
0answers
46 views

How to get incoming pending transactions for an address using web3py and full node data?

I lunch a geth node in fast mode using geth --testnet --fast and I want to get incomming(pending) value for an account address using web3py, like web3.eth.subscribe('pendingTransactions') in web3js. ...
1
vote
1answer
32 views

Connecting to Rinkeby using Infura and calling a state-changing function from smart contract

So i have trouble using a smart contract on Rinkeby through infura as it gives an "extra-data" error, which as far as i have read, is due to Rinkeby being a POA testnet. There are suggestions of using ...
2
votes
0answers
37 views

Creating new accounts using `web3`

In the new version of web3.py, the personal.newAccount functionality has been retained only for the geth client. What is the right cross-client approach to creating new accounts? See v5 migration ...
0
votes
1answer
33 views

Web3.py cannot connect to geth --dev node via IPC

I've launched a geth client over IPC: geth --dev --allow-insecure-unlock --ipcpath ipc://$HOME/Library/Ethereum/geth.ipc And trying to connect using a Web3 IPC provider: my_provider = Web3....
2
votes
3answers
46 views

How to get the actual time of occurrence for ethereum transaction in block

I used the API of Ethereum to download some transactions info. The timestamp is included, however I found the timestamp not mean the transaction time but the block which this transaction is located ...
3
votes
1answer
31 views

ShhFilter: ValueError: {'code': -32000, 'message': 'filter not found'}

For web3.py==v5.0.1: web3.geth.shh.newMessageFilter used to return the filter on v4.x.x but now it only returns the filter_id, so I received the filter object using w3.eth.filter(filter_id='0x'). ...
1
vote
1answer
95 views

AttributeError: 'Web3' object has no attribute 'middleware_stack

web3.py version: 5.0.1 , Python: 3.6.3 Following code was working on web3==4.9.2, which does not work for the web3==5.0.1. I am getting following error: web3.middleware_stack.inject(...
0
votes
1answer
46 views

How to connect to Rinkeby without using Geth / Parity?

First let me explain my development environment. I am using Jupyter Notebook to play around with the Web3.py front-end code and Remix for the Solidity smart contract code. I am using the Metamask ...
0
votes
1answer
17 views

How can I find the block where a user enacted a certain event on a contract?

I'm trying to build a web3.py program to take in a given user's address, and return the amount of ETH traded since they added liquidity to a Uniswap exchange. Uniswap is a smart contract on the ...
0
votes
0answers
16 views

How to obtain data from a private PoA Ethereum Network?

I want to fetch data from a private PoA ethereum network running on a local computer. The data will be used for anomaly detection. I need contract interaction data (function calls etc.), to observe ...
3
votes
2answers
90 views

Web3Py - How to convert from Gwei to Wei or Ether

i know there is web3.fromWei('myamount','ether') to convert from Wei to Ether. But what if i have only the GWei amount?
2
votes
2answers
87 views

Analogue web3.eth.accounts.sign (from web3js) in web3py

There is a function web3.eth.accounts.sign in the implementation of web3js. But I cannot find the exact equivalent in web3py I don't see this. I found something similar to this — the signHash function ...
1
vote
0answers
59 views

How to pass a struct as an argument in call using web3.py

Following is a working code on remix. It is recommended to use memory keyword for the struct parameter. Please also see: Solidity Storage Array Bugs Which does not work on Web3.py and gives the ...
1
vote
1answer
39 views

How to sign a transaction locally

Is there a way in web3.py to create a wallet of accounts similar to web3.js to sign the transactions locally without building a raw transaction? web3.js code: var provider = new Web3.providers....
0
votes
1answer
69 views

Getting Error:VM Exception while processing transaction: revert', 'code': -32000. when deploying to Ganache using Web3.py

I get the following error message: Getting Error:VM Exception while processing transaction: revert', 'code': -32000 I am connected to Ganache. Here is my code: import json from web3 import Web3 ...
2
votes
1answer
78 views

solcx compile_files Key error

I am using python package py-solc-x for compiling the smart contract. os.path.abspath("D:/new.sol") Gives path where my test contract exits. 'D:\\new.sol' Then i use compile_files to compile the ...
1
vote
0answers
39 views

Connection dropped by Kaleido websocket

Connecting to Kaleido with websockets and listening on contract events works fine, but after some time (even if constantly receiving events) the connection is dropped by Kaleido. The problem appears ...
1
vote
1answer
75 views

How to access Parity node's mempool with web3.py?

I'm running a Parity node with parity --jsonrpc-api all, then connecting to it in python3 with w3 = web3.Web3(web3.HTTPProvider('http://localhost:8545')). I can call print(w3.eth.getBlock('latest'))...
0
votes
0answers
11 views

How often should the Web3.py provider connection be shared in a django project?

My django project directory structure is the following ... projectRoot projectName __init__.py settings.py urls.py wsgi.py App1 __init__.py admin.py models.py ...
0
votes
1answer
62 views

How to create a local account from an external private key in Web3.py?

I've been using local_account = w3.eth.account.create(keys['private_key_1']) to create a local account offline. When I check the public key returned from local_account.address it does not match the ...
2
votes
2answers
42 views

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 ...
0
votes
0answers
19 views

Pass a list of structs as a contract function parameter in web3py

I am using web3py version 4.9.2 and wanted to find out if there is any way to call a contract function with an array of structs as enabled by the new ABIEncoderV2 functionality? The relevant solidity ...
0
votes
1answer
217 views

How to send struct data as function input on Remix or web3 call?

I've created a function which gets a struct which contains int+struct. Now when I want to test it, what data should I send for example on Remix: here's the code, got from another SO question on - ...
0
votes
1answer
187 views

How exactly do you decode input data using web3.py using the decode_function_input?

My goal is to decode the input data placed in a transaction on Ethereum. My current example is to look at the MKR-ETH contract on Uniswap. Normally you can see how much ETH goes into a transaction, ...