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

TimeoutError when using Infura websocket with web3.py

When I run the following code, sometimes it run OK, most of the time it gave error: concurrent.futures._base.TimeoutError code: if __name__ == '__main__': infura_url_ws = 'wss://mainnet.infura....
0
votes
0answers
14 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
31 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
25 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
33 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. ...
0
votes
1answer
13 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
35 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
25 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
43 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
25 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
52 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
26 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
16 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
15 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
46 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
74 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
48 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
31 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
52 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 ...
0
votes
1answer
59 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
31 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
50 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
9 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
52 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 ...
1
vote
1answer
31 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
14 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
158 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
119 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, ...
1
vote
1answer
38 views

What is the best way to push transactions with hight rate (>1000 per second)?

In order to test the throughput of a private Ethereum, I need to send multiple transactions as fast as possible. Can web3js ensures fast delivery of transactions? or there is an other more efficient ...
1
vote
0answers
95 views

AttributeError: 'list' object has no attribute 'buildTransaction'

Im trying to send a transaction to contract function with web3.py on ropsten testnet. while doing so, Im getting this error. AttributeError: 'list' object has no attribute 'buildTransaction' here ...
0
votes
1answer
74 views

how to send transaction with web3.py

I'm trying to use web3.py with infura.io to interact with my smartcontract. here is my simple greeter contract code pragma solidity ^0.5.7; contract greeter{ string greeting; function greet(...
0
votes
0answers
86 views

Web3py AttributeError: 'HTTPProvider' object has no attribute 'manager'

I am trying to use web3 in a Django based web application in a task which is run using celery and kafka. However while trying to use web3.eth module, I am getting the following error : /...
1
vote
1answer
82 views

web3.py web3.isConnected() returns false always

I am trying an tutorial on web3.py so i created a profile in infura and used its project id.But it shows false always when i try web3.isConnected() PS C:\Users\HP> python Python 3.6.3 (v3.6....
1
vote
1answer
32 views

How to access a smart contract function protected by access rights using Web3?

I have a smart contract address for security tokens, and certain functions of it are protected by access rights, for which I have an address to access those functions, however I am not able to figure ...
2
votes
1answer
128 views

How pass a struct as an argument in call from python code

How call this contract functions from python code? pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; contract MY_PERSONS { struct Person{ string name; uint age; } ...
0
votes
0answers
52 views

How to make ECDSA signature of (value_1, value_2) with web3 on Python?

I want to call function with four parameters. I know how to create two of them, but the last two is the r and s components of ECDSA signature of (param_1, param_2). I tried this (and a lot of ...
1
vote
1answer
59 views

web3.isConnected returns False web3.py

Here is the code I have: from web3 import Web3 infura_url = 'https://infura.io/project/MyProjectID' web3 = Web3(Web3.HTTPProvider(infura_url)) print(web3.isConnected()) The problem is that it ...
1
vote
1answer
148 views

How to save new account in ganache-cli [duplicate]

I use ganache-cli --db to create a private test chain and save it on my computer, and the result is below: I use web3py w3.personal.newAccount('1') to add a new address, and I use print(len(w3....
2
votes
0answers
14 views

Most efficient way to get all non-zero storage locations for a smart contract?

I'm looking at a mainnet smart contract and want to figure out all storage positions/slots where the storage has a non-zero value. Is there a way to do this other than replaying and tracing all ...
0
votes
0answers
32 views

call() returning BadFunctionCallOutput in web3.py

Have a very basic ERC721 contract based on OpenZeppelin-Solidity, as follows: pragma solidity ^0.5.7; import 'openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol'; import 'openzeppelin-...
0
votes
1answer
30 views

How to understand from web3py if I need a transaction or a call

I have a contract with a function in which only if a certain condition is true, it changes the state of the blockchain otherwise it emits an event and returns: address[] public global_state; function ...
3
votes
0answers
42 views

Block Timestamps vs. Received Timestamp

I've been logging local timestamps when I receive blocks on two separate geth nodes to see which (if any) is consistently faster. But I just stumbled across something that I don't understand - in my ...
0
votes
1answer
54 views

How to pass constructor arguments in web3.py

I'm trying to deploy smartcontract with web3.py. below is my simple smart contract: pragma solidity ^0.5.0; contract homeAutomation{ string public greeting; constructor(string memory _greet) ...
0
votes
1answer
47 views

How do I get the transaction fee used by a transaction in web3py

I am using web3py to do transactions for token and ether. Now I need to keep a track of transaction fee applied for each transcation. How can I get the transaction fee from transaction hash?
1
vote
1answer
233 views

How to get the value of the transaction?

I am using web3.py but I need help to know the value of the transaction sent. I know that the information is stored in the input but how do I parse the string. I know nothing about ABI. Here is the ...
0
votes
0answers
19 views

How to completely empty an Ethereum wallet using W3.py

I have an ethereum wallet, I need to calculate the amount to completely empty the wallet. So currently i calculate the needed gas like this, needed_gas = w3.eth.gasprice * 210000 amount_to_send = ...
0
votes
0answers
138 views

Genearte error 'invalid sender' when doing send transaction using infura or roopsten

I am using following code to perform transaction web3 = Web3(HTTPProvider('https://ropsten.infura.io/{}'.format('XXXXXXXXXXXXXXXXX'))) print('https://ropsten.infura.io/{}'.format('XXXXXXXXXXXXXXXXXXX'...
1
vote
0answers
54 views

How to send transaction using web3py using infura.io

I have connected to mainnet via infura.io and have used http provider for connections now i want to generate address and send transaction And i wand to send real eth so how can i do this?...
1
vote
0answers
116 views

How to transfer transaction and send balance on public blockchain using web3py api?

I have followed tutorial and setup private Blockchain using geth: https://medium.com/infrageth/practical-steps-for-go-ethereum-setup-27b8d64903fc I have used web3py python library for creating ...