Questions tagged [python]

Python is a dynamic and strongly typed programming language designed to emphasize usability.

Filter by
Sorted by
Tagged with
1
vote
0answers
298 views

How to convert my metamask private key into 32 bytes hexa

How to convert my metamask private key into 32 bytes hexa ? i am using web3 to start trading on pancake but when i try to convert my bsc metamask phrase keys into hexa is like 150 bytes but require ...
2
votes
2answers
72 views

deploying a contract private key error

I am following tutorial entitled "DApp Development for Python Programmers" by levelup.gitconnected. The url is https://levelup.gitconnected.com/dapps-development-for-python-developers-...
3
votes
2answers
245 views

How can I get the hexadecimal equivalent for a method name in an Ethereum contract using Python?

The function to call is called xyz(). My code: web3.sha3("xyz()").substr(0,10) Error: AttributeError: module 'web3' has no attribute 'sha3' In newer versions of web3, the above error ...
0
votes
1answer
71 views

Contract Event Filter returning empty array when using get_all_entries Web3.py

Python Version: 3.9.6 Web3.py Version: 5.21.0 Used Geth and Infura (HTTPS and Web Sockets) Tested on Ethereum Mainnet and Kovan I have tried this before about a month ago with the exact same code and ...
1
vote
2answers
503 views

How to get smart contract information about ABI token balance by web3?

when I get ethereum block data like below... from web3 import Web3 w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545')) print(w3.isConnected()) block = w3.eth.get_block('latest') it can get block ...
2
votes
0answers
235 views

Brownie INFO: Could not find files for the given pattern(s)

I installed Brownie succefully, and also am able to make a init project from it. But every time I run brownie I get INFO: Could not find files for the given pattern(s) I've installed ganache-cli, ...
1
vote
1answer
364 views

Subscribing to new block headers using python (web3py)

I am looking for a subscribe function in web3py like the one implemented in web3js: web3.eth.subscribe('newBlockHeaders' [, callback]); As there currently is no implementation of it in web3py, has ...
0
votes
1answer
930 views

Web3 Python token sell pancakeswap

I am trying to sell my tokens via python web3. But sometimes I get an error "execution reverted: Pancake: K". I researched this error and it has to do with the slippage but pancake swap docs ...
0
votes
1answer
110 views

Is there a way to poll totalSupply of an ERC20 token on a specific Block?

I am using web3.py, and i am trying to get block-specific data of some ERC20 token contracts. Also, i tried with Google's BigQuery, but both seem to give the totalSupply at the 'latest' block. Is ...
0
votes
0answers
230 views

brownie.exceptions.RPCRequestError when calling a function from contract using Brownie

Encountering the following issues calling a contract w/ Brownie v1.14.6 on mainnet-fork w/ infura. Note that pool_lens = interface.FusePoolLens("0x8dA38681826f4ABBe089643D2B3fE4C6e4730493"). ...
0
votes
1answer
575 views

Uniswap web3 python

Hi everyone I am getting the error below when I try to write to a Uniswap function using web3 in python. I can call any function, but I cannot get python to write to uniswap except to add liquidity. ...
1
vote
1answer
105 views

How to predict profit from swapExactEthforTokens to swapExactTokensforEth?

I am using Python and web3.py. I have to swap eth to tokens using swapExactEthforTokens in Uniswap. And then I have to tokens to eth using swapExactTokensforEth in Uniswap. How do get calculate profit?...
0
votes
1answer
161 views

How to get a token pair's entire uniswap trade history?

I'm trying to query the entire transaction history of a given pair (e.g. WETH/USDT). Hence, this question is similar to How to get a token pair's uniswap trade history? My approach is to use the ...
0
votes
1answer
98 views

Unable to set NFT tokenURI with web3py

I have the following contract method: function setTokenURI(uint256 tokenid, string memory uri) public { require(bytes(uri).length != 0, "Cannot set an empty URI"); ...
1
vote
0answers
40 views

eth_call for nameExpires(uint256 id)

Can someone please explain how I can build the eth_call data param for Registrar nameExpires(uint256 id) the signature is this: 0xd6e4fa86 The function takes id of label, the namehash. BUT i dont ...
5
votes
1answer
1k views

Will I have to change how I set raw transaction gas price for eip-1559?

I have a question about setting gas prices after the new hardfork. Currently the software I'm working with uses the ethgasstation.info api to select a gas price and then publishes a raw transaction ...
0
votes
1answer
104 views

Where can I find the polygon.curve.fi interfaces for solidity?

I am trying to interact with the aave curve pool. I have the interface for the curve polygon pools, but they are written in vyper not solidity. https://github.com/curvefi/curve-contract-polygon/blob/...
1
vote
0answers
74 views

Losing connection on Geth websocket subscription

I am trying to keep multiple WebSocket connections to my Geth node open at the same time (around 200 connections). My issue is that they keep closing with a timeout error. I can't seem to know if it's ...
0
votes
0answers
31 views

How do I store an integer in solidity smart contract function using python

I am wanting to store a value in the smart contract function store with python. Box.sol contract Box { uint256 private _value; // Emitted when the stored value changes event ValueChanged(uint256 ...
0
votes
1answer
572 views

eth-brownie: Unable to expand environment variable in host setting

When running a script: brownie run scripts/deploy.py --network kovan I receive this error: raise ValueError(f"Unable to expand environment variable in host setting: ‘{uri}’”) ValueError: Unable ...
0
votes
0answers
92 views

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....
1
vote
1answer
50 views

How to compare / sort address in Python?

I need to ensure address0 < address1 in Python. Solidity compares this directly, but how to do it in Python? (Or in any other programming language) I would guess that addresses need to be converted ...
1
vote
1answer
179 views

How to input decimal parameter in web3.py?

I have a contract with this abi [ { "stateMutability": "nonpayable", "type": "constructor", "inputs": [ {"name": "...
0
votes
0answers
19 views

Stream BSCscan API?

I'm using API of BSCscan to get some info about a coin. There is a way to get a "stream" of data from BSCscan ? to get some info faster. Because my main problem right now is i do one call, ...
0
votes
1answer
848 views

How to get a pending transaction? I am using python with web3py

I am using the URL "https://mainnet.infura.io/v3/key". But I can't get a pending transaction. This is my code. pendingTransaction = web3.eth.filter('pending') I had an error like this. The ...
0
votes
1answer
155 views

Can you check if an address is a contract or an EOA with eth-brownie or some other python native package?

I'm trying to categorize smart contracts versus EOAs since I am treating them differently in an application. Does anyone have ideas? I know in solidity you could try address.code.length or extcodesize ...
0
votes
0answers
682 views

Pancakeswap Error when trying to swap token to BNB using Web3.js and Python

I have written a Swap in python using web3.js. I can't seem to get it to work when I try to buy BNB for tokens. The transaction is created, but the Pancakeswap router gives me the following error: ...
0
votes
1answer
210 views

How can I automate NFT generation via code?

Pardon me if I sound lame. I have read tutorials about creating NFT in Solidity but those examples were for a single item. How sites like Openseas create NFT contracts on the fly, especially when you ...
3
votes
2answers
673 views

Web3: Get token address from pair address

I am studying all listed pairs on Pancakeswap. I get the pair address from PCS_FACTORY_ADDRESS="0xca143ce32fe78f1f7019d7d551a6402fc5350c73" PCS_FACTORY_ADDRESS = Web3.toChecksumAddress(...
1
vote
0answers
51 views

AttributeError: 'list' object has no attribute 'encodePacked' when calling a smart contract function with web3.py

Here is the pycharm code: import json from web3 import Web3 ganache_url = 'http://127.0.0.1:7545' web3 = Web3(Web3.HTTPProvider(ganache_url)) web3.eth.defaultAccount = web3.eth.accounts[0] ...
1
vote
1answer
45 views

isConnected() is freezes and returns nothing in web3.py

I use: python3.7, web3==4.9.2, Infura and/or own Node. After web3 was initialized it returns isConnected() response only in first time, after that it freezes. web3.py: from web3 import Web3 from web3....
0
votes
0answers
19 views

GraphQL retrieves incorrect values reserveUSD, token0Price and token1Price

I am using the Uniswap API on graphQL to try to receive the reserve data for every token pair on Uniswap. Following the directions on their website am able to generate a list of all the correct pair ...
0
votes
1answer
224 views

How to connect Metamask with Web3.y

I know Meta Mask is a frontend Google Chrome extension. I want to know how my DApp can find the client's current wallet. Should I check if web3.js is enabled and check the availability of Meta Mask ...
1
vote
0answers
17 views

Tronscan transactions python3

I try get transaction on tronscan. from tronapi import Tron from tronapi import HttpProvider full_node = HttpProvider('https://api.trongrid.io') solidity_node = HttpProvider('https://api.trongrid.io')...
2
votes
1answer
141 views

Call fallback function from eth-brownie from proxy

I have a contract that has a fallback function to delegatecall all function calls to a different contract. I can't seem to use my typical API to interact with the contract it delegates a call to. I ...
0
votes
2answers
25 views

How smart contract can PULL data from the outer world?

Sorry in advance if I do not make sense as I am a traditional developer now entering in Solidity/Smart Contract world. For learning purposes, I want to build a simple online commerce system where ...
0
votes
1answer
473 views

ModuleNotFoundError: No module named 'brownie._cli'

After installing python3, ganache-cli, upgrading pip to pipx and installing eth-brownie.. I am receiving errors when trying to use "brownie". I followed all of the steps in their docs ...
0
votes
1answer
200 views

when sending a str, it must be a hex string. Got: "'MY _PUBLIC _KEY'"

web3s.py from web3 import Web3 import json url = 'https://kovan.infura.io/v3/NODE' web3 = Web3(Web3.HTTPProvider(url)) abi = json.loads('[{"ABI"}]') Raw_ADDRESS = MY_ADDRESS address = ...
1
vote
0answers
114 views

Web3.py _PyEval_EvalFrameDefault returned a result with an error set

I am trying to read data from a pancakeswap contract and i started getting the _PyEval_EvalFrameDefault returned a result with an error set and would crash the thread and subsequently the process that ...
0
votes
1answer
743 views

How to use Web3.WebsocketProvider for continuously receiving the last block from own Node in Python

I use python 3.7 and own Node. So i want to receiving every last block from own Node immediately after it was mined. from web3 import Web3 WEB3_WS_URI = 'ws://node_url:8546' w3 = Web3(Web3....
1
vote
1answer
136 views

Convert keccak256(abi.encodePacked(idToSeed[id])) in python

I am looking for python syntax to draw the autoglyphs using python. Here is the few lines which I want to convert in python. I am new to it. Please help me out with this. uint a = uint(uint160(...
0
votes
0answers
17 views

Cannot import 'VRFConsumer', 'PriceFeed', 'APIConsumer', and 'interface'

I'm new to brownie ( but not new to python) and am trying to get a basic project running to make sure everything works. I've been going off the Patrick Collins tutorial where uses the chainlink mix. ...
2
votes
1answer
535 views

Is there any way to get pending transaction for specified address?

is there any way to get pending transaction for a specified address? I can filter them on bscscan here, but I can't do the same in my web3py code. I can get all pending transaction for current pending ...
0
votes
1answer
2k views

PancakeSwap Execution Reverted

I've been tring to code a bot to run on pancakeSwap and for some reason, all the transactions I try with this script keep getting reverted. API_URL = 'https://data-seed-prebsc-1-s1.binance.org:8545/' #...
1
vote
1answer
108 views

Ganache gives error when I try to mint token to wallet after contract deploy

i use: python 3.5, docker, ganache (image image: trufflesuite/ganache-cli:v6.9.1) what do i do: (simplified example) I have two container: container with ganache and container with general logic. ...
1
vote
2answers
618 views

Error: Non-hexadecimal digit found

I seem to be running the following error when I try to run this script: , from brownie import AdvancedCollectible, accounts, network, config def main(): dev = accounts.add(config['wallets']['...
0
votes
0answers
96 views

Re-create raw transaction hash from transaction object

Is there a way to re-create the signed transaction hash from tx object. I found the How to construct a raw Ethereum transaction from transaction data answer helpful, but when I try to re-create the ...
1
vote
0answers
90 views

IPFS hash link keep loading without not responding

I'm trying to add many JSON files in IPFS using the following API from this liberary py-ipfs-http-client, after running locally ipfs daemon: client.add('item.json') And here is the output of the item....
4
votes
1answer
3k views

How to create and send Flashbot transactions?

So far, I only understand flashbot bundles are signed raw transactions with one of them being a bribe to the miner for the mining fee, but : Is the bribing transaction special in the way it is valid ...
1
vote
0answers
162 views

How to manually interpret balance change after custom Events using web3.py

Context I am trying to build my own Ethereum explorer. I know this already exists on Etherscan out-of-the-box but the features that I want are either rate-limited or not even provided via its API. To ...

1
2
3 4 5
8