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
1 answer

*** web3.exceptions.BadFunctionCallOutput: Could not transact with/call contract function, is contract deployed correctly and chain synced?

I running ganache on my local and deployed my contract to it using brownie console ❯ brownie console Brownie v1.17.1 - Python development framework for Ethereum BeautyEthereumProject is the active project. Brownie environment is ready. >>>…
joe
  • 8,383
  • 13
  • 61
  • 109
3
votes
5 answers

Compute the LP Address of a token pair using web3.py

I managed to have this code run after few hours of searches but unfortunately, this does not produce the output I wanted which is to get the LP Pool Address in (TOKEN/BNB LP). Given the Token Address: 0xe56842ed550ff2794f010738554db45e60730371 I…
rbutrnz
  • 383
  • 4
  • 20
3
votes
0 answers

When I call the balanceOf function for a contract and specify a block number in call(), I receive a forbidden URL error

When I use contract.functions.balanceOf(wallet_address).call(block_identifier=block_num) I get a forbidden URL error, but if I run the same call without using the block_identifier argument, it works as expected. What is the reason that this is…
juju
  • 884
  • 1
  • 9
  • 31
3
votes
1 answer

Calculating price of BSC token with Web3 and Python

I'm building a tool with web3 and python that needs to quickly and accurately get prices of tokens on Binance Smart Chain via PancakeSwap. The tool gathers information about BSC tokens, price, liquidity etc so I can further analyse rugpulls. In the…
James
  • 101
  • 2
  • 10
3
votes
2 answers

How to get all transaction data from the entire Ethereum network using web3py

I'm trying to run some analysis on cryptocurrency(e.g. Bitcoin, Ethereum) data but having trouble finding data sources. For example, I'd like to collect transaction data such as input address, output address, transaction time, transaction amount,…
user16599218
3
votes
1 answer

Python equivalent to Solidity u256

I am working on a Solidity Smart Contract. The idea is to automate some of the tasks using Python. So I have this code: idx = 1 event_id = cDF.iloc[idx]["A"].astype(int) event_date = cDF.iloc[idx]["B"].astype(int) x =…
Martin Rasumoff
  • 1,463
  • 1
  • 11
  • 12
3
votes
4 answers

bsc get transactions by wallet address Web3.py

How can I track tokens transactions of a list of wallets in the bsc network? I think about using websocket and filter function. I think it's possible to use the topics as a part of the filter parameters and reflect only the Transfer event to/from…
R0ixy
  • 91
  • 1
  • 1
  • 5
3
votes
2 answers

How to get ERC20 Token Transaction of a specific contract using Web3py

I'm using web3py and I want to get the transaction history of a specific contract. Here's my code sample eventSignatureHash = web3.keccak(text='Transfer(address,uint256)').hex() filter = web3.eth.filter({ 'address':…
The Bassman
  • 2,241
  • 5
  • 26
  • 38
3
votes
1 answer

Calculating price using Web3py and Uniswap pair smart contracts: How to deal with fixed point numbers?

I'm trying to calculate the price of a token in Uniswap using web3.py and a Uniswap pair contract, but I must be doing something wrong with the math. Example: I would like to calculate the price of one ETH denominated in USDC. I first connect to the…
Karim
  • 31
  • 1
  • 2
3
votes
3 answers

Function invocation failed due to no matching argument type. web3.py, Python

I'm trying to swap tokens using swapExactTokensForTokens() (Pancakeswap Router function). Here is my code def swapTokens(): amountIn = (w3.toWei(0.00001, 'ether')) amount1 = contractR.functions.getAmountsOut( amountIn, [wbnb,…
3
votes
2 answers

Discrepancy in web3.contract.functions.getAmount()

I'm using Web3.py and I'm experiencing something strange. For the following code (with Pancake Router V2): from web3 import Web3 from web3.middleware import geth_poa_middleware web3 =…
EvgenyKolyakov
  • 3,310
  • 2
  • 21
  • 31
3
votes
2 answers

web3.py swapExactTokensForTokens failing transaction

I am trying to call swapExactTokensForTokens of a router contract, I need to swap tokenA to tokenB. Here is the code of the transaction: router = '0x0000000' abi = '[{"inputs":[{"internalType":"address","name":"_factory","type":"address"},....…
Zaza
  • 51
  • 1
  • 3
3
votes
0 answers

Why doesn't the Web3.py transact function work?

I am trying to follow an online tutorial, but I am getting errors all the time. Can someone please help me? I cannot find any answer that could by handy. Solidity code: pragma solidity ^0.5.0; contract Greeter { string public greeting; …
Filip Szczybura
  • 407
  • 5
  • 14
3
votes
0 answers

This library has been renamed to `eth-utils`. The `ethereum-utils` package will no longer recieve updates. Please update your dependencies

When I try to link the Python file to the smart contract i run python3 "project name ".py command i get the error Traceback (most recent call last): File "1_accounts.py", line 2, in from web3 import Web3 File…
israa
  • 31
  • 2
3
votes
1 answer

How to transfer an ERC20 token between wallets with web3.py

I was wondering, what is the proper way to transfer an ERC20 token between two wallets using web3.py? I am testing everything on the Rinkeby test network. Here is what I've tried... from ethtoken.abi import EIP20_ABI from web3 import…
bond00719
  • 33
  • 1
  • 5