7 votes
Accepted

Getting Uniswap v2 latest price and interpreting values using Python

Dev advocate at Chainstack here. You can get prices directly from the Uniswap V2 pair contract, like you are attempting now, by analyzing the reserves of each token in the pair. The key to obtaining ...
Dave Dev Advocate Chainstack's user avatar
3 votes

How to sign message EIP-712 with whitespace in name?

Metamask's typed-data signing implementation is more permissive than eth-account's encode_structured_data. A new python implementation is in process that will be more compatible with EIP712 signing as ...
pacrob's user avatar
  • 181
2 votes
Accepted

How to know token transfered in pending status from memepool

You need to decode input params. You can do this if you know ABI of the smart-contract address. In your case it is not hard. Smart contract address: 0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B ABI (go ...
valentinmk's user avatar
2 votes

Calling contract method(0x..) using web3.py

0x0eb0d6a5 looks like a function selector. You can use Contract.get_function_by_selector() to fetch this function using the selector.
selcukwashere's user avatar
2 votes

Sign_transaction and send_raw_transaction error in Web3.py

There are a few issues. If it's just Python syntax, then you are missing commas and the dictionary for row: # Fixed commas and row.id and row.trust_value for row in addresses_df.itertuples(): ...
Ake's user avatar
  • 1,109
2 votes
Accepted

Manually RLP-encoding an ETH tx gives an incorrect result

You need to convert tx["to"] to bytes before encoding. You also have tx["yParity"] where tx["v"] should be, per your syntax guide. from rlp import encode from web3.types ...
pacrob's user avatar
  • 181
2 votes
Accepted

Decode json.loads(log_event) using python web3

Is there a pre-existing way to do this conversion w/in the web3 library or do I need to create my own converter? For decoding textual JSON-RPC response, you can reuse the code from web3.py, namely ...
Mikko Ohtamaa's user avatar
2 votes

Getting Uniswap v2 latest price and interpreting values using Python

Here is an example how to get the last price on Uniswap v2 compatible DEXes using web3-ethereum-defi Python package. The PairDetails class will do an automatic conversion of prices to human-readable, ...
Mikko Ohtamaa's user avatar
2 votes
Accepted

Cannot create the same ECDSA signature with Web3.py and ethers.js

For ethers.js version 6, the code will be slightly different: let signer = new ethers.SigningKey(privateKey); let messageHash = await ethers.solidityPackedKeccak256([ "string", "...
Alexey Smirnov's user avatar
2 votes
Accepted

Good resource for web3 developer

I believe each person have their own style of studying new thing. For my experience here are some good resources and learning path that you can follow: First, you need to understand the basic of BC ...
tqdpham96's user avatar
  • 608
2 votes

Trouble making UniV2 swap on Sepolia with web3py

Because you use function swapETHForExactTokens, thus, you have to define "value" when build_transaction to send ETH with transaction. That why in the transaction hash you can see 0 at value ...
tqdpham96's user avatar
  • 608
2 votes
Accepted

Uniswap web3 py buy token fails with execution reverted

This looks like a decent script & it should work. What I'd look for is: If your account has enough ETH for the swap If the token that you are trying to get as a result has fees in the contract &...
Ake's user avatar
  • 1,109
1 vote
Accepted

Warning! Error encountered during contract execution [execution reverted] when doing a swap using pancakeswap router on bsc testnet

Prior to executing the swap transaction, you need to set the allowance for the router contract to spend WBNB on your behalf. Here's a quick Python code that shows there's 0 allowance for the router ...
Ake's user avatar
  • 1,109
1 vote

How to make contract transactions with Web3.py

It's possible your blockchain doesn't support the Shanghai update. Since solidity v 0.8.20, the compiler implements the new opcode PUSH0, which your blockchain might think it's invalid. So, change the ...
0xSanson's user avatar
  • 3,139
1 vote

I met difficulties: web3. Exceptions. Web3ValidationError:

When I change the deposit content to “params = ['0xDepositor','0xRecipient', amount_uint256, chainID_uint256, int(relayFeePct_uint64), int(timestamp_uint32), b"", maxCount_uint256]”, it ...
黑大帅's user avatar
1 vote

I can´t create a new folder

It is difficult to understand your problem but as i understand your question if you are not able to create folder on remix this is how you can create folder on remix At the end file you can create ...
Ilyas Khan's user avatar
1 vote

contract abi not working if json format

Triple quotes turn your ABI into a string instead of a dictionary. If you want to go the string route, you need to turn the string back into a data structure with something like json.loads (that will ...
Ake's user avatar
  • 1,109
1 vote
Accepted

How do I hide or mask the sending address when sending tokens or eth

In order to prevent funds from being easily tracked on the blockchain, you could use a Mixer. Mixers allow users to deposit an amount of tokens, and then withdraw the tokens from another address that ...
Rohan Nero's user avatar
  • 1,577
1 vote

SushiSwap contract RouteProcessor: Unknown command code

Route Processor: route breakdown (with working example) To build a route you'll want to know what you want to do, then look for those stages in the contract. There are command bytes and pool bytes ...
Maka's user avatar
  • 860
1 vote

Problem with web3.py + pyinstaller

Version 6.6.0 had a problem with the necessary json files not being included. If you specify 6.6.1 you should be fine. Support for v5 is due to stop in August.
pacrob's user avatar
  • 181
1 vote
Accepted

Problem with web3.py + pyinstaller

use web3==5.31.4 not use web3>=6.*
dick's user avatar
  • 26
1 vote

How to use signer details from ethers.js to sign transactions with web3.py

You can not use the signer provided by MetaMask to sign transactions without the approval of the user, unlike a signer created using a private key.
selcukwashere's user avatar
1 vote
Accepted

How to decode a log['data'] hexBytes from a solidity event using web3.py

As you can see in the image below the Data field consists of five different attributes and by calling through the below web3 API it returns the hex bytes of those five attributes combined. w3.eth....
Usman Farooq's user avatar
1 vote
Accepted

Where can I find the ABI for PancakeSwap RouterV2?

You can find the ABI here Oftentimes smart contracts are verified on block explorers.
Willbrand's user avatar
  • 166
1 vote
Accepted

Can web3.py be used from a server like aws lambda?

Yes, although you would need to store a private key in your lambda. You can use this to retrieve the key securely: https://aws.amazon.com/blogs/compute/securely-retrieving-secrets-with-aws-lambda/ In ...
lordarora's user avatar
  • 296
1 vote
Accepted

How to get the a block's hash given its number to then feed to filter?

The fromBlock should be a block number, not a block hash, so it have to be like that: eventFilter = web3.eth.filter( {"fromBlock": 1000, "topics": [...
Saxtheowl's user avatar
  • 668
1 vote

How do I sign a message using web3py?

If you are trying to sign a transaction and interact with a smart contract. You can have a try with the code below tokenInstance = w3.eth.contract(address="Target Contract Address", abi= &...
KoNit.'s user avatar
  • 11
1 vote

Does eth-brownie require using web3py below version 6?

Brownie is no longer very actively maintained and may not work with the latest Web3.py versions. You might want to migrate to ApeWorX.
Mikko Ohtamaa's user avatar
1 vote

processRoute SushiSwap

You say your error is cannot import name 'encode' from 'eth_abi', but in your code you use eth_abi.encode_single which was deprecated so as to not use different code for decoding single vs multiple. ...
pacrob's user avatar
  • 181
1 vote

Decoding Pending Transaction Input Web3 Python

You are almost there! The main issue is that you are using the wrong contract and tx data in this example. The transaction you are trying to decode is to PancakeSwap V3, but you are using the V2 ...
Dave Dev Advocate Chainstack's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible