Questions tagged [python]
Python is a dynamic and strongly typed programming language designed to emphasize usability.
685
questions
0
votes
2
answers
11
views
Runtime error: code size to deposit exceeds maximum code size
I'm using solc_version version 0.8.16, which i checked is installed, but when i'm trying to deploy the contract getting error Runtime error: code size to deposit exceeds maximum code size. While using ...
0
votes
0
answers
19
views
Uniswap V2 router contract call fails with TransferHelper: TRANSFER_FROM_FAILED
The scan link is here: https://wemixscan.com/tx/0x717a6385a15f896a08dc9e6ca3980cdd7443ca8a88a0ab5944522c61200c06a8
I'm trying to swap between WWEMIX(Wrapped Wemix token) for WEMIX$ (Wemix dollar) by ...
0
votes
0
answers
7
views
How do I propose a transaction with safe-eth-py?
I am working with the safe-eth-py package to script safe transactions. So far, I have only been able to execute transactions when the safe is set to accept a single signer. How can I propose a ...
0
votes
0
answers
11
views
Ask for help using Python's ETH library web3.py and py-evm to splice Receipt trie and encounter problems
def _build_tree(self, transactions, receiptsRoot):
from rlp import encode, sedes
from trie import HexaryTrie
from eth.rlp import receipts, logs
def zpad(x, l):
return b'\x00' * ...
0
votes
0
answers
15
views
using boto3 to access objects in Linode, getting Invalid endpoint error
I'm following the documentation to connect to object storage with boto3 here:
https://www.linode.com/docs/products/storage/object-storage/guides/aws-sdk-for-python/
Here is my code
linode_obj_config =...
0
votes
0
answers
71
views
how to buy tokens with python web3 in pancakeswap v3
can someone give me an example of how to buy tokens in python web3 with the v3 version of pancakeswap? I don't understand what parameters I have to pass to the multicall() function.
1
vote
0
answers
17
views
Can we rely on 1inch Swap API price feeds
It is not clear to me how 1inch swagger API is getting the prices from different dexes. Can we rely on them? As they are not open-sourced. I tried using the aggregator but faced this issue RPC timeout ...
1
vote
0
answers
31
views
Function invocation failed due to no matching argument types web3 python
I am trying to access smart contract but its returns
Could not identify the intended function with name createEscrowOrder, positional arguments with type(s) int,address,float and keyword arguments ...
0
votes
1
answer
69
views
Manually RLP-encoding an ETH tx gives an incorrect result
I fetched a mempool tx
AttributeDict({'blockHash': HexBytes('0x92911a95b4d4b07bb13552bfb29cc43bf43eb7d63af7c968ddaa3df9a6f22988'), 'blockNumber': 17964189, 'from': '...
0
votes
1
answer
57
views
How to call `quoteExactInputSingle` on quoter2 uniswap using python
I'm trying to call like this in ape
def SushiswapV3quoteExactInputSingleV3(
router,
_from,
tokenIn: str,
tokenOut: str,
fee: int,
amountIn: int,
sqrtPriceLimitX96: int = 0,
...
0
votes
1
answer
14
views
How to remov installed package with Ape Python smart contract framework?
Does anybody know how to remove package installed with ape pm? Brownie has brownie ethpm remove [package-name] Or I should just delete folder in ~/.ape/packages?
0
votes
0
answers
30
views
removeLiqudityWithPermit: Invalid Signature
So, I am trying to remove liquidity from a pancake v2 pair and I do not understand why this is not working. I am looking at the code, and I've triple checked every value, I don' think I am doing ...
1
vote
0
answers
43
views
web3.py is not routing properly as pancakeswap finance GUI
I have a script in python in order to execute a multicall using pancakeswap V3 router contract. Muticall sells some tokens using "swapExactTokensForTokens" from the contract. The path ...
2
votes
1
answer
119
views
InvalidStatusCode: server rejected WebSocket connection: HTTP 401
I am trying to subscribe to pending transactions on the Ethereum blockchain using this tutorial from Infura: https://docs.infura.io/tutorials/ethereum/subscribe-to-pending-transactions
When I try to ...
1
vote
0
answers
256
views
has anyone seen this error installing brownie?
Banging my head against a wall trying this. have tried uninstalling cytoolz, pipx, and reinstalling but keep getting this error trying to install brownie.
Collecting click==8.1.3 (from eth-brownie)
...
0
votes
3
answers
91
views
Problem with web3.py + pyinstaller
I used web3.py to create a program, and turned it into an exe with pyinstaller, but now I am getting this error when I try to run the exe:
Traceback (most recent call last):
File "main.py",...
0
votes
0
answers
8
views
Does Brownie support structs and enums?
Brownie is a seemingly popular framework for testing smart contracts (both solidity and vyper) in python.
I've just gotten started with brownie and my first few tests are working. However, I can't ...
0
votes
0
answers
26
views
Querying for Ethereum nodes (like how ethernodes.org does it)
I'm wondering how https://ethernodes.org/nodes works on the backend.
Did they just have a script using devp2p discovery.py (https://github.com/ethereum/pydevp2p/blob/develop/devp2p/discovery.py) or ...
0
votes
0
answers
25
views
Translating decoded multi-swap transactions into Buys/Sells
How can I determine if a transaction is a buy or a sale of a certain token?
I'm taking as an example this multi-swap transaction:
Decoded tx data from Moralis: https://pastebin.com/xhtFrnb2
Right now ...
0
votes
1
answer
70
views
How to call smart contract methods without abi?
I need to call a smart contract from python, but it is not verified. Since this is not my contract, I cannot verify it. How to call the smart contract methods through python in this case?
Smart ...
0
votes
0
answers
24
views
AttributeError: 'Eth' object has no attribute 'abi'
I am building a web application using django to register phone battery details and it interacts with a smart contract. I am trying to use the decode_log method but I keep getting this error:
...
0
votes
0
answers
45
views
Cannot get info about position in liquid pool
I tried to get my position info in PancakeSwap liquid pool. I want to know how much token0 and token1 I added and how much uncollected fees exist.
I found this field in PancakeV3Pool contract:
mapping(...
0
votes
1
answer
1k
views
Provider error: transaction would cause overdraft: I got this error when deploying to sepolia testnet
require("@nomicfoundation/hardhat-toolbox");
require('dotenv').config();
const { ALCHEMY_SEPOLIA_RPC_URL, WALLET_PRIVATE_KEY } = process.env;
console.log(ALCHEMY_SEPOLIA_RPC_URL);
module....
1
vote
2
answers
34
views
eth_rlp: AttributeError: module 'rlp' has no attribute 'Serializable'
Brownie won't initialise. Even after clearing paths, pipx, installing new versions.
0
votes
1
answer
182
views
Where can I find the ABI for PancakeSwap RouterV2?
Where can I get the PancakeSwap ABI?
I have a simple code, but I don't understand where to get ABI
pancakeaddr = '0x10ED43C718714eb63d5aA57B78B54704E256024E'
abi = ?
contract = web3.eth.contract(...
2
votes
1
answer
55
views
Tool to re-create state of smart contract locally
I would like to be able to simulate transactions with smart contracts based on their solidity source code. The process should be entirely automated.
While I am aware that some tools allow forking the ...
0
votes
1
answer
15
views
reproducing solidity address() in python
the below solidity code converts 29144403828894911802891993729705329970730667872118118 to 0x690a87Ed8972e451e755b8F2dC1fc2B28e3c6566
I would like to reproduce this in python but have come up short. ...
0
votes
0
answers
37
views
I cannot perform a purchase function on a marketplace. I get execution reverted
I'm trying to execute a purchase function in a marketplace and I can't, I get a return error and I can't understand how to resolve the error.
from web3 import Web3, HTTPProvider
from web3.middleware ...
0
votes
3
answers
228
views
How to call ethers.utils.defaultAbiCoder.encode(types, values) in python?
I want to create a signature based on a hash value and a wallet address.
In nodejs I would do it like follows:
const types = ["address", "bytes32"];
const values = ...
0
votes
1
answer
96
views
Can web3.py be used from a server like aws lambda?
I am developing a web3 application whose some part of backend code runs in a python script hosted on an aws lambda server. However, from this python script I will also be calling certain functions of ...
0
votes
1
answer
127
views
Transforming Ethereum ABI(JSON) into Human-Readable ABI in Python
I know there is one example to do it: ethersjs implementation
But how to transforming Ethereum ABI into Human-Readable ABI in Python?
0
votes
1
answer
49
views
Unable to call functions on a deployed contract through web3py
I have a working private network in which i have successfully deployed a contract using python. I have its address and i can see the deployment in the node log, but i cant call any functions and it ...
0
votes
1
answer
121
views
AttributeError: 'exactInputSingle' object has no attribute 'buildTransaction'
I want to swap tokenA to tokenB. Thequestion heppened:
File "E:\Code\pythonProject\infura_API_test\3_swap_by_web3_py.py", line 76, in <module>
tx_swap = router.functions....
0
votes
0
answers
29
views
Connecting to Frontend DAapp with python using walletconnect (python, pyWalletConnect)
i am trying to create a bot in python to connect to a dapp. I'm trying to use pyWalletConnect lib, but it's new and challenging.
I have successfully retrieved the URI i need to connect to, but i have ...
0
votes
1
answer
235
views
How to encode a solidity struct in python?
I have in solidity:
struct MyStruct {
string data;
address issuer;
}
function getHash(MyStruct calldata myStruct) public pure returns (bytes32) {
return keccak256(abi.encode(myStruct));
}
...
0
votes
0
answers
13
views
Load last N blocks with eth-defi python
Using the web3-ethereum-defi lib and JSONRPCReorganisationMonitor how do you only load the last N blocks? This code wants to load data from block 0 to latest.
reorg_mon = JSONRPCReorganisationMonitor(...
0
votes
1
answer
136
views
Function invocation error showing exactly the data types i provided
I Was trying to interact with a smart contract named clearingHouse and use the function "openPosition", I went ahead and matched the data types as they were described using python3 web3 ...
2
votes
2
answers
98
views
How do I sign a message using web3py?
How can I sign this message using web3py?
Based on the documentation, I realized that I need to use eth_signTypedData. But it is not clear to me how to send data (space, proposal, choice, etc.).
0
votes
1
answer
53
views
What version of web3py does ApeWorX support and does it also support account impersonation (unlock account) without needing the private key?
What is the most recent web3py version that ApeWorX supports? I need to have support for unlocking random eth accounts on a local test network (ex: http localhost 8545) through something like hardhat (...
1
vote
1
answer
109
views
How to read all Transfers on blockchain
How do I get all transfers occurring on the blockchain and their transaction amounts and to and from addresses?
event_signature_hash = web3.keccak(text='Transfer(address,address,uint256)').hex()
...
0
votes
0
answers
185
views
Uniswap V3 reverts execution on 'quoteExactInputSingle' function
I am working on goerli testnet with uniswap and trying to get token price with fee included. In order to accomplish I call uniswap.get_price_input python uniswap library function. It runs perfectly ...
0
votes
1
answer
205
views
web3 python - AttributeError: 'Eth' object has no attribute 'abi'
I am trying to use an example ABI but its not being found.
My problem is on last line:
AttributeError: 'Eth' object has no attribute 'abi'
infura_url = 'https://mainnet.infura.io/v3/xxx'
web3 = Web3(...
0
votes
0
answers
92
views
Sepolia Unauthorized URL
Good day, Ive constantly been getting errors while working with Sepolia Test Eth with Brownie, I've checked for errors in my .envfile as well as in my brownie-config and still havent seen a ny issues, ...
0
votes
2
answers
412
views
Decoding Pending Transaction Input Web3 Python
I am writing some code on Python utilising the Web3 library. I am accessing the mempool and I am trying to access the slippage on pending transactions on swaps made on the Binance Smart Chain with ...
0
votes
0
answers
51
views
Dependency Conflict Between Slither And Brownie
I have encountered strange issue and I'm not sure how can I fix it permanently. I had brownie (similar to hardhat) tool installed and once I have installed slither those 2 seems to have some conflicts,...
1
vote
1
answer
27
views
How does web3.py knows my private keys when calling write smart contract function with transact?
Im using web3.py 6.0.0 with code:
import os
import json
from pathlib import Path
from web3 import Web3
import time
from dotenv import load_dotenv
load_dotenv()
class SmartContractInterface:
def ...
0
votes
1
answer
91
views
Send bytes32 data to a smart contract using python
How to send data to a function which takes bytes32 as the input parameter.
1
vote
0
answers
112
views
Python | eth_utils | Public Ethereum Address derivation from Public key not working
I have the below, trying to derive the Ethereum Address from public key (working) using keccak and to_checksum_address on eth_util, but doesn't match up with derivation on iancoleman.io or miguelmota....
1
vote
0
answers
68
views
Python script Same seed combination doesn't derive same address
This script runs great but for some reason, it doesn't derive the same results as iancoleman.io m/44'/60'/0'/0/0 with the same seed words combination..can anyone spot it?
import itertools
import ...
1
vote
0
answers
126
views
How to find the Bytecode of Ethereum Smart Contract by just it's address
Hi actually I found the answer & I just wanted to share this with the community
You can use the web3.py or brownie module of Python to achieve this
web3.py
from web3 import Web3
# Connect to ...