ethereum

web3.py function get_block tranactions is not in the current block

web3.py function get_block tranactions is not in the current block Question: I want to synchronize all transactions with the database, so I use get_ Block method. The code is as follows: cur_block_num = web3.eth.get_block_number() if cur_block_num <= last_block_num: return res = web3.eth.get_block(cur_block_num, full_transactions=True) block_info = json.loads(web3.toJSON(res)) block_info = convert_numeric_to_str(block_info) transactions = block_info.pop(‘transactions’) db["block_info"].insert_one(block_info) but When …

Total answers: 1

trying to use web3.py but no methods seem to work

trying to use web3.py but no methods seem to work Question: trying to use web3.py V5.31.1 with infura as a websocketprovider, but no methods seem to work. The only method that works is w3.eth.chainId my code: from web3 import Web3 import web3 w3 = Web3(Web3.WebsocketProvider(‘wss://mainnet.infura.io/ws/v3/myapikey’)) print(w3.eth.chainId) #w3.clientVersion –#doesnt work #w3.is_connected() –#doesnt work try: print(web3.eth.get_block(‘latest’)) except: …

Total answers: 1

PyScript with Ethereum

PyScript with Ethereum Question: I am still learning about the new PyScript in browser. I was wondering if it is possible for me to allow a click button to check if MetMask account is connected. In regular JS we use to write the following: However, in PyScript, I am not sure how to get the …

Total answers: 1

buy and sell in one transaction in Web3, to check for honeypots

buy and sell in one transaction in Web3, to check for honeypots Question: How can i turn this buy function into a transaction that buys and sell in a single transaction? The reason behind this is to check if a token is a honeypot and will not allow me sell the token, but i dont …

Total answers: 2

smart contract with brownie gives VirtualMachineError

smart contract with brownie gives VirtualMachineError Question: I encontered a problem when I test my project, any help would be greatly appreciated. All my code can be found in here: https://github.com/Karlus44/smartcontract-lottery When I type the command brownie test my script tests/test_lottery_unit.py is exectuted, and my different tests are submitted. Here some quotes of my logout: …

Total answers: 3

The transaction declared chain ID 5777, but the connected node is on 1337

The transaction declared chain ID 5777, but the connected node is on 1337 Question: I am trying to deploy my SimpleStorage.sol contract to a ganache local chain by making a transaction using python. It seems to have trouble connecting to the chain. from solcx import compile_standard from web3 import Web3 import json import os from …

Total answers: 6

web3 python getAmountsOut execution reverted

web3 python getAmountsOut execution reverted Question: I managed to set up this function that returns the token value in USD of a contract, everything works fine in some contracts, but in other contracts I get the error "execution reverted" when calling the function "getAmountsOut" does anyone have any idea what it can be? I get …

Total answers: 1

ParserError: Source file requires different compiler version

ParserError: Source file requires different compiler version Question: I tried all that you mentioned in the discussion here (in other questions) and at https://github.com/smartcontractkit/full-blockchain-solidity-course-py/discussions/522 , however it is not solving the issue for me, I also noticed that the current compiler version remains (current compiler is 0.6.12+commit.27d51765.Windows.msvc). But when I right click and select Solidty:Compiler …

Total answers: 5

'code': -32603, 'message': 'Error: Transaction reverted without a reason string' while i'm trying to use swapExactTokensForTokens UNISWAP

'code': -32603, 'message': 'Error: Transaction reverted without a reason string' while i'm trying to use swapExactTokensForTokens UNISWAP Question: I have read documentation on this function. I’m using Hardhat to visualize Blockchain at a particular moment. I deposit() ETH to WETH, then I approve() WETH to router. Everything looks fine. But when i try to call …

Total answers: 2