Questions tagged [web3.py]
Web3.py helps you access your Ethereum node from Python. It is web3.js for Python.
970
questions
0
votes
0
answers
15
views
Web3 python websocket persistent connection
I am implementing a crypto payment system for my django web app. I have a smart contract that exposes some functions that let users purchase credits for my application by sending crypto to the smart ...
0
votes
1
answer
69
views
How to swap a token on UniswapV3 in python
Question:
I've been able to successfully write scripts for swapping tokens on Uniswap V2, but I'm facing challenges when trying to swap tokens on Uniswap/PancakeSwap V3. Specifically, I am trying to ...
0
votes
0
answers
37
views
when using call function in web3.py im getting error
Error: Could not transact with/call contract function, is contract deployed correctly and chain synced?
import streamlit as st
from web3 import Web3
import hashlib
import json
# Connect to local ...
0
votes
0
answers
41
views
Calculating Uniswap V3 pool address in Python
I'm trying to use Python to calculate the pool address of two tokens based on the Uniswap V3 Solidity code provided here.
Here's my Python code:
from web3 import Web3
from eth_abi.packed import ...
0
votes
1
answer
17
views
ContractContainer still empty in Brownie after contract Deployment
Please I know this question might be a repetition of what was previously asked here but the answers didn't solve my problem.
In my case I actually used the brownie run scripts/deploy.py --network ...
0
votes
0
answers
20
views
Web3ValidationError when calling contract function using web3.py
I am trying to deploy a trading bot and trying to call a contract function called simpleSwap. here is the function in the abi:
{'inputs': [{'components': [{'internalType': 'uint256',
...
1
vote
0
answers
24
views
expired transactions using flashbots eth_sendPrivateTransaction
I'm trying to send a swap transaction using eth_sendPrivateTransaction to alchemy, which then routes it through private mempools using flashbots. But my transactions keep expiring. I have tried adding ...
0
votes
0
answers
20
views
uint256, uint8 and bytes32 in the called smart contract function. [calling smart contract function i nweb3.py]
I want to call a function with certain parameters in web3.py but I have no idea how to specify the parameters in the called function. What are the data types uint256, uint8 and bytes. Can you provide ...
0
votes
1
answer
37
views
Can't connect to an Ethereum node using WEB3_PROVIDER_URI environment variable in web3.py
I am trying to connect to an Ethereum node using the environment variable WEB3_PROVIDER_URI in web3.py. The documentation says:
Alternatively, you can set the environment variable WEB3_PROVIDER_URI ...
0
votes
1
answer
52
views
find which mapping and slot a key belongs to
How is it possible to know which mapping a key belongs to?
For storage mappings how is it possible to know if a key belongs to a mapping or another?
For example, there are 2 mappings on the contract (...
0
votes
0
answers
8
views
I have issues buying Base Coins. Error: Fail with error 'TransferHelper: TRANSFER_FROM_FAILED'
web3= Web3(Web3.HTTPProvider(alchemy))
#print(web3.is_connected())
#Instancia contrato uniswap
uniswap_router_contract = web3.eth.contract(address=botuni, abi=abiBot)
# Crear instancia del contrato ...
0
votes
1
answer
28
views
web3.py Increase the amount of gas to make the transaction faster in the blockchain
My goal is to have my transaction included in the blockchain as soon as possible.
This code, includes the transaction in the blockchain in 5-7 seconds in eth and polygon.
tx = {
'from': w3....
1
vote
0
answers
32
views
Why signing a transaction needs a RPC call
I am using web3.py to build and publish my transaction. Observing that the send_transaction()'s latency is quite high, I split the function call into a "sign" and "send raw", as ...
0
votes
1
answer
24
views
Web3.py gas_price does not exactly match value from transaction
I'm using the web3 python provider to get the value of the gas_price property, but when I compare it with the value from an Etherscan transaction it is slightly off. Could this be just due to timing?
...
1
vote
1
answer
51
views
How to know why Uniswap cancelled my transaction?
I am not pro, but can someone check please why my transaction was cancelled on Ethereum after sending to Swap token on Uniswap v2?
https://etherscan.io/tx/...
0
votes
1
answer
86
views
when sending a str, it must be a hex string. Error in Web3.toChecksumAddress function
I get an error when I try to run the following code
cc = "0x483a49dcf80B932cf94734B8fd5d3p9aa508a933"
ToAdd = Web3.toChecksumAddress(cc)
The error I get.
when sending a str, it must be a ...
1
vote
1
answer
154
views
Reading Ethereum JSON-RPC data faster using web3.py
I know this kinda of question has been asked many times but none of them seem to meet my expectation. I am looking to extract total historical block transaction eth-values and also historical balances ...
1
vote
0
answers
20
views
Golang ABI coding Why does coding overflow occur?
The incoming data is the same, why does python output: :...
0
votes
1
answer
34
views
Error: Provider not set or invalid (safari + chrome problem)
I have deployed an ERC20 token on Sepolia. See it here: https://augustwarshauer.com/AugustCoin
It's hosted on github pages, so I cant use node or anything (if I can, news to me).
In my chrome browser, ...
1
vote
1
answer
50
views
How to estimated balance changes by web3.py
I am simulating the information obtained before the interaction between the wallet and the contract in the figure below through web3.py. I want to obtain the Gas fees and benefits before the actual ...
0
votes
1
answer
82
views
How to monitor new pairs and liquidity pools in mempool pending transactions?
I have a task to monitor newly created pairs PairCreated() and adding new liquidity pools Mint(). That is some kind of sniper bots like banana or maestro that are watching mempool and send buy ...
0
votes
0
answers
27
views
After implementing UniswapV3 swap logic in Web3.py, I get a lot of logic errors saying "execution reverted: SPL"
I tried to do a Swap on UniswapV3 with the following code in Web3.py.
As a flow, output the value of amount_out_min in quoteExactInputSingle function -> get the pool impact after the swap in ...
0
votes
1
answer
35
views
Is there Uniswap V2/V3 function to get initial token supply amount in pool?
I need to get initial token supply when liquidity pool was created by querying Ethereum node (RPC) or Uniswap contract and not Mint() function, is it possible to do (python)?
To get reserves on any ...
0
votes
0
answers
12
views
Help with addLiquidtyEth keeps returning either transfer_from Failed or OVERFLOw
Im trying to add all tokens to liquidity. It doesnt allow the amount of tokens desired to be more then the total supply so im not sure why it keeps returning 'execution reverted: pancake: OVERFLOW'
Im ...
0
votes
2
answers
27
views
reserve0/reserve1 price is different compared to boughtTokensAmount/requiredWeiAmount
I would start with a sample on exact UniswapV2 pair SHIB/WETH (SushiSwap). I use local hardhat node and there's no possibility of 3-rd party effect on LP.
I have this toSwapTokensAmount = ...
0
votes
1
answer
342
views
how to call execute sell function in uniswap v3?
I have called function buy and sell with uniswap v3 and transaction is failed. How to call
I use web3py and call to
def sell_token(web3 : Web3 , chain, wallet_address, address_token, token_abi, ...
1
vote
1
answer
41
views
Contract.functions "not found" in Web3.py
Testing this python code on UBUNTU :
import requests
import json
from eth_account import Account
from web3 import Web3, HTTPProvider
caller = "0xb9****f832860DBD"
private_key = "...
0
votes
1
answer
100
views
Decode Safe transaction data with web3py
The transaction from Safe multisig is executing a contract so it cannot be decoded it directly with the contract ABI. The Safe transaction includes data field with long hex string starting 0x6a761202 ...
0
votes
0
answers
81
views
web3.exceptions.ContractLogicError: execution reverted: STF (I approved)
amount_in_max,path,uniswap_contract_address,uniswap_router_abi=self.preview_swap(uniswap_router,token1,token2,amountin)
deadline = int(time.time()) + (60 * 20)
w3 = Web3(Web3.HTTPProvider(...
0
votes
1
answer
128
views
solidity_keccak not matching JS keccak256(abi.encodePacked(
I'm trying to reproduce a signature that a contract verifies but I'm unable to do it on web3py. To verify I'm producing a signature correctly I'm going to look at an already produced signature and ...
0
votes
0
answers
22
views
Scan transfers of token on ethereum using web3.py
I am trying getting specific token transfers value using web3.py library. I succeeded getting all transactions where in the transaction there is the token transferred.
My problem is that the value ...
0
votes
1
answer
374
views
How can I get a private key from a mnemonic phrase? in python or other [duplicate]
I have a mnemonic phrase for my wallet. I want to use it in Python. Is there a way to I get a private key from a mnemonic phrase?
I want to get litecoin wallet's private key
1
vote
0
answers
54
views
Optimism Swap problem in Web3.py
Error in code when trying to swap from Optimism to usdt or usdc via Web3.py library
I have code that swap successfully to Arbitrum, Polygon but error in Optimism.
I am using MetaAggregationRouterV2 ...
0
votes
0
answers
267
views
How to swap one coin to another in Web3.py using Uniswap contracts?
I want to make an exchange from MATIC in order to get USDC.
I'm using Infura web3-RpcUrl. I'm open to use any router contract like swap, 1inch, uniswap, sushiswap etc.
My code partially works, as I'm ...
0
votes
0
answers
95
views
Is there a way to speed up vanity address generation with GPU / Cuda / Mojo?
Currently using Python to generate a vanity address with basically this notebook - https://github.com/wolovim/ethereum-notebooks/blob/master/Address%20Mining.ipynb
Anyone know how to incorporate the ...
0
votes
0
answers
197
views
Swap on Pancake swap V3 using web3.py
How can I programatically swap this transaction (https://bscscan.com/tx/0xeb82366f808d194bcae4ede724bb0dbaeebc431fe492ff70b1c3c7a5d5762d47) using web3.py?
When swapped from their official webgui they ...
1
vote
0
answers
46
views
Web3.py is contract deployed correctly and chain synced?
I'm trying to deploy a contract via web3.py on a local test chain.
def deploy_contract(w3, file_path, contract_name, gas=2000000):
with open(file_path, 'r') as f:
source = f.read()
...
0
votes
1
answer
32
views
Etherscans ABI and transaction receipt topic[0] are different. Bug?
I need simply to get Transfer data values from transaction with 1 log https://etherscan.io/tx/0x6465187a7bb43a6db42ee63e5f5cc30fb094393957a7f1ce6c08b5afddf3e0bc. It sends +7,601.747 LINK.
The problem ...
0
votes
0
answers
49
views
Etherscan API doesn't return internal transaction (although it has)
Here is transaction https://etherscan.io/tx/0x33e0dab83aa27ba8b2a08b3c69d61a34911a4adb6e7a35dd30cf11383f43fcc3 with simple Transfer() some GALA tokens.
Etherscan shows 1 internal transaction:
But it'...
0
votes
1
answer
61
views
Why Etherscan's API missing ABI functions?
Here is transaction https://etherscan.io/tx/0x0db6f8036ca7ea58bf4a8799bbf62bb30e3431d644d37d4030c27ac0d22f7542#eventlog
In logs we can see 3rd function SendToInjectiveEvent(). It is interaction with ...
1
vote
1
answer
421
views
Ethereum transactions: how decode already decoded input data?
Here is transaction https://etherscan.io/tx/0x1a70dafba58e5cbc10adecb18e2489613b298a4aab0ecb2cbbbfd2ba184cdc39
It makes Swap 0.095 ETH for 1,125.066 VDO on Uniswap V2.
If to scroll down, press More ...
1
vote
0
answers
74
views
How do I derive public key from mnemonic (StarkNet)
I have some problem with that, since StarkNet is so different from evm. I be gratefull for any docks or article about this.
1
vote
0
answers
89
views
Transaction stuck and blocking any new transactions, but changing node provider solved it. Why?
Can someone please help me understand what just happened, so I and others can account for this in error handling?
I was using web3.py to swap USDC for WMATIC through the UniswapV3 Router on Polygon ...
2
votes
1
answer
66
views
1inch spot price aggregator fails for some historic blocks but not others
I am trying to price arbitrary ERC-20 tokens at past blocks, and it turns out this is a challenging problem. Currently, I query the Uniswap v3 subgraph at a past block, but this doesn't always return ...
0
votes
1
answer
296
views
Disconnected from ETH websocket after timeout error [Python]
i'm trying to listen to eth websocket using python's web3 library, particularly listening to log events.
async def ws_v2_subscription_context_manager_example():
while True:
try:
async with ...
0
votes
1
answer
191
views
Token Balance not changing after simulating swap on uniswap v2
Hi I am trying to mock the process of buying and selling token through uniswap v2 router.
I start with a local network fork anvil --fork-url https://mainnet.infura.io/xxx
Then I have to do 2 things ...
0
votes
2
answers
64
views
MethodUnavailable(error) when shifting from Ganache to Sepolia Testnet
I previously used Ganche to deploy a solidity contract in python with web3py and it worked with given http provider & account details. But now I want to deploy the flask application that connects ...
1
vote
1
answer
186
views
Uniswap web3 py buy token fails with execution reverted
I have been trying to buy tokens on uniswap V2 with we3 py with swapExactETHForTokens function. Every time, I try to execute this method it fails with execution reverted message. Can somebody please ...
0
votes
2
answers
161
views
Token swap not working on uniswap v2
I am trying to use web3 to swap tokens in uniswap. My swap ( ETH -> Token) is working correctly, but for some reason the reverse swap ( Token -> ETH) does not seem to work. I am not able to find ...
3
votes
0
answers
67
views
How to create a "Transaction history" part of a Wallet App?
guys! Right now I am working on web3 project, which has a wallet as it's one parts. Can you give me advices on how to create this Transaction History for user, because I am kind of stuck on it.
First ...