5
votes
Accepted
How to get MethodID of a function in a smart contract?
The function selector or method id is the first 4 bytes of the hash of the method name and the parameters. This is documentend here https://solidity-by-example.org/function-selector/
More details are ...
5
votes
How to call certain solidity function based on python function parameter
Yes you can call functions based on parameters that you want in web3.py and is very simple.
Connect to a node provider (I recommend Chainstack.com as they provide nodes for many networks and supports ...
4
votes
Is there any way to see the txpool with infura and web3?
The standard Infura endpoint does not allow you to do that. I would suggest to use Chainsack, you can create a free node and allows you to do it. I have a repo showing exactly that in python using ...
4
votes
Accepted
Programmatically wrap ETH by interacting with Wrapped Ether contract in Web3.py
You just have to call the deposit() function of the WETH contract and define the number of ETH to be wrapped to WETH in the transaction's value key.
Example of working, unsigned tx:
tx = weth_contract....
3
votes
Accepted
Brownie: Constructor Sequence has incorrect length, expected 1 but got 0?
Try using this solidity code:
https://github.com/PatrickAlphaC/brownie_fund_me/issues/1
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.6;
import "@chainlink/contracts/src/v0.6/interfaces/...
3
votes
Estimated Pair Price VS Real Output Price Problem
I finally fixed it!
And yes it was indeed a gap in my Uniswap knowledge.
I thought that the pool reserves are always stored in ether, but they are stored in the token amount with the appropriate ...
3
votes
can't connect to web3 using websocket method
turns out the script was fine. it was the WSS endpoint that wasn't working.
3
votes
How do I call functions from 'Read as proxy' on smart contracts?
same exact way. Just pretend it's there and it should work. Instantiate the contract with the ABI that you want to call (e.g. the one with balanceOf regardless of it's actually there or not)
2
votes
How to find out if a token takes a fee on transfer?
I have seen lots of tokens with different dynamics to get some fee. Some wallets are even exempt from paying those fees giving false positives in the analysis.
What works for me in python using web3....
2
votes
Creating similar output as EtherScan "Transaction action" with web3.py
The logs get converted to human-readable output via ABI. You can construct Contract instances in web3.py and then use event methods to parse the output from raw JSON-RPC data to human-readable data ...
2
votes
How to use estimateGas() in web3 py?
You have to estimate on the built tx, not the signed. For your code that would be the transaction variable.
2
votes
How to get Transaction Action Etherscan
I asked Etherscan support and got the answer.
We unfortunately do not have an endpoint that returns the "Transaction Action" information at this point of time.
It is a popular one by ...
2
votes
getting "Import "web3" could not be resolved" error
It works regardless of the VS Code error, better still you can restart your VS Code and the error will be gone
2
votes
Accepted
Quote received from 0x swap API returns no valid, unsigned transaction?
It's valid for most javascript web3 libraries, which typically ignore unused fields. YMMV with Python. It looks like you might just need to prune those excess fields.
2
votes
Accepted
Send transaction with Brownie without confirmation wait
so you just need to pass 'required_confs':0 dict with request like that:
token = interface.ERC20(tokenContract)
token.transfer(toAddress, amount, {'from': account, 'required_confs':0})
2
votes
Calling Smart Contract function from python. Execution Reverted Error
Okay, self own..
So to anyone else starting out.. the answer to this is always make sure you are using the right token addresses. In my code here, the weth address is completely wrong for ropsten.
2
votes
i am getting attribute error while running erc20 brownie project on rinkeby testnet
here is another solution: you can leave your get_account() as is. instead of commenting out the two lines like Ganesh's solution, you can add the rinkeby network in your yaml file.
This is because if ...
2
votes
Accepted
What is the name of the ether unit with 4 and 8 decimals?
You can achieve this by updating the dictionary units located in the eth_utils/units.py file in the eth_utils that is a dependency of the web3 codebase.
For me it lives here C:\Python38\Lib\site-...
2
votes
Accepted
Why geth fast sync or light sync does not get the latest highest block
I faced exactly the same problem (last block 13773036). The solution was to update the geth to the latest version.
2
votes
Error publishing source code
It seems to me more like an etherscan issue to be honest. I'm also having this problem for about 2 hours now, testnet transactions are going through just fine, but etherscan hangs on "indexing&...
2
votes
Error publishing source code
I am having the same problem when trying to deploy my contract using rinkeby network.
Though when I try to run the following link
Replace MY_ETHER_API_KEY with your api key from etherscan
https://api-...
2
votes
Accepted
Sending a transaction despite ContractLogicError
Is there a way for me to build the transaction without the smart
contract validation, package it up and send it. This risks my contract
failing on the chain and costing me gas fees, but it's a risk I'...
2
votes
Accepted
How can i get a uniswap pool address using web3py?
The method UniswapV3Factory.getPool(address tokenA, address tokenB, uint24 fee) returns the pool address of a given pair, given the pair token addresses and the pool's fee parameter.
The problem with ...
2
votes
passing array of struct as a function argument (web3.py)
You are just not giving the inputs in the right format.
I used a simplified version of your contract :
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Example {
struct ...
2
votes
Can I get more specific metadata for a certain transaction hash from a basic RPC connection (e.g. Infura)
You can use web3.js / ethers.js method getTransactionReceipt
await provider.getTransactionReceipt("0x_your_tx_hash");
It returns raw data of the transaction, all events, etc.
To check if a ...
2
votes
Accepted
Which gets executed faster, a Solidity function or a Web2 backend function?
Basically do everything off-chain that you can. It saves gas, time, and space on the EVM. I think the only arguments for doing more on-chain:
usually more user friendly if no nice front end (front ...
1
vote
Accepted
How do you verify a Metamask signature on the server side?
Here is what worked for me:
You will need a Web3 provider, for example:
w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/api_key')
You can recover the address using the message and signature ...
1
vote
getting "Import "web3" could not be resolved" error
hi I'm also doing that same course,
its not at all problem unless u installed web3.py successfully
its fine VS code will show it as error but Web3 will work fine when every u run
python deploy.py
in ...
1
vote
web3.exceptions.ValidationError: with tuple[], address, bytes
The problem was that r, s values did not conform to bytes32.
Passing the following did not work.
signature = "0x........"
r = "0x" + signature[2:66]
s = "0x" + signature[...
1
vote
Accepted
How to recover public key using ecRecover in Python?
You will need to instantiate the web3 object and cannot refer to a package here.
from web3 import Web3, HTTPProvider
w3 = Web3(Web3.HTTPProvider(<infura or alchemy URL>))
def verify(request, ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
web3.py × 815python × 244
solidity × 148
web3js × 141
go-ethereum × 88
transactions × 68
etherscan × 42
brownie × 39
infura × 38
blockchain × 36
events × 34
ganache × 31
pancakeswap × 31
erc-20 × 28
uniswap × 26
contract-development × 25
bsc × 25
tokens × 23
ether × 23
contract-invocation × 21
abi × 17
polygon × 17
web3-providers × 16
remix × 15
metamask × 14