psudeo code:
from web3 import Web3
# Connect to an Ethereum node
w3 = Web3(Web3.HTTPProvider("http://localhost:8545"))
# Get the block number
block_number = w3.eth.blockNumber
# Get the block object
block = w3.eth.getBlock(block_number)
# Loop through all the transactions in the block
for tx in block['transactions']:
print(tx)Transaction(transaction_hash)
# do something with the transaction details
print(transaction)
Dec 8, 2022, 5:40 PM
I think looping through the transactions to see their structure will be a good start.
Dec 8, 2022, 5:41 PM
Here's what I'll get then:
AttributeDict({
'blockHash'
'blockNumber'
gas':
'gasPrice':
hash
input
nonce
to
transactionIndex
value
type
'v'
r
s
But there is no method😭😭😭
AttributeDict({
'blockHash'
'blockNumber'
gas':
'gasPrice':
hash
input
nonce
to
transactionIndex
value
type
'v'
r
s
But there is no method😭😭😭
Dec 8, 2022, 5:42 PM
You wont see it as "method"
https://blockchainlion.com/ethereum-transaction-structure/
Dec 8, 2022, 5:43 PM
Check each transaction separately? Then it will be long😞
But this is not possible... Blocks are generated quickly! Gotta write Buterin
Dec 8, 2022, 5:49 PM
What are you trying to do exactly ?
Look at transactions, or are you trying to monitor events or are you trying to see the mempool?
Because without more context its difficult to help/give direction
Dec 8, 2022, 5:50 PM
Track events! When a block appears, I need to find out if it has a certain Method id
Dec 8, 2022, 5:51 PM
Then you need to bind to a particular address and listen for events.
not just "look all the transactions in a block looking for an address"
Thats super inefficient
Dec 8, 2022, 5:51 PM
See if there is an address in the block, and then parse the method from the etherscan website ☹️
Dec 8, 2022, 5:52 PM
You should look at listening to contract events if you want to monitor a particular contract
Dec 8, 2022, 5:53 PM
Parse?
Something like this:
url = ('https://etherscan.io/address/'+str(adresse))
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
result = requests.get(url, headers=headers)
html = result.content
soup = BeautifulSoup(html, 'html.parser')
I'll try. Let's see how fast I fall behind😁
Something like this:
url = ('https://etherscan.io/address/'+str(adresse))
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
result = requests.get(url, headers=headers)
html = result.content
soup = BeautifulSoup(html, 'html.parser')
I'll try. Let's see how fast I fall behind😁
Dec 8, 2022, 5:54 PM