1

I wonder if anyone can assist please? I have searched the forum but I cannot find anything that answers my specific question.

I'm trying to parse the input data from transactions on the following contract (Titan X) :-

0xF19308F923582A6f7c465e5CE7a9Dc1BEC6665B1

  1. When I look at a typical transaction called a 'Start Mint' function on Etherscan I see this :-

enter image description here

  1. And when I click on the Transaction hash, I see this :- and on there I can see a clickable link called 'More Details' :-

More Details

  1. When I click on '+ Click to Show More' I can see a field called 'Input Data' :-

enter image description here

  1. There are always and only 2 Hexadecimal data that appear in this field :-

(a) Mint Power [0] (b) Number of Days 1

  1. Could someone please help me to extract this data within a controlled speed loop, that does not exceed the maximum ETH API call rate for a user defined range of block numbers. I'd like to populate an excel spreadsheet with the Date, Mint Power and Number of Days.

Any help would be much appreciated.

Thank you very much in advance.

3 Answers 3

1

Q.D. Pham,

Thank you very much for answering my question.

I've loaded up the libraries that you're using into my Python IDLE, and I have run your code with my Etherscan API transposed into your code.

Unfortunately, I get a persistent error at Line 15 in mintPower as follows :-

============== RESTART: C:/Python311/parse mint data for titanx.py ============= Traceback (most recent call last): File "C:/Python311/parse mint data for titanx.py", line 15, in mintPower = int(inputs[10:10+64], 16) ValueError: invalid literal for int() with base 16: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\

Do you know what the problem might be please?

Thanks.

0

Sorry for not answering directly to your reply because I do not have enough points. I believe the error comes from the transaction input. You may parse the wrong one.

It would be great if you can print the "inputs". If you parse correctly, the value of inputs should be something like this (according to this transaction https://etherscan.io/tx/0x958ccfe41ea002afe69234aa10a106ba5e87d6807ccaf6b3a23a5826bfc1399f):

enter image description here

Hope it helps you.

0

Basically, there are two approaches to decode the value of Mint Power and Number of Days.

#1: Using abi-decoder and/or parseTransaction utilities for web3. The details can be seen in this How to decode input data from a transaction?

#2: Decode manually based on the input data based on the following rule. The input data represented in blockchain is illustrated as bit string.

  • The first 10 bit string is the transaction signature which is 0x635d70f4 in your example
  • Next 64 bit string represents the first input (which is mintPower)
  • Next 64 bit string represents the second input (which is numOfDays)

=> Thus, you just need to slice the input string to decode from hexadecimal to decimal.

Given the following transaction https://etherscan.io/tx/0x958ccfe41ea002afe69234aa10a106ba5e87d6807ccaf6b3a23a5826bfc1399f

You can create a Python code snippet to decode it as

from web3 import Web3
# Connect to an Ethereum node 
web3 = Web3(Web3.HTTPProvider('https://rpc.ankr.com/eth'))

# Incase you have a list of txns to decode
listTxns = ['0x958ccfe41ea002afe69234aa10a106ba5e87d6807ccaf6b3a23a5826bfc1399f']
# SafeMint signature
for txn in listTxns:
    trans = web3.eth.get_transaction(txn)
    inputs = trans['input']

    # 0:10 is transaction signature
    mintPower = int(inputs[10:10+64], 16)
    numOfDays = int(inputs[10+64:10+64*2], 16)
    print('mintPower: ', mintPower)
    print('numOfDays: ', numOfDays)

Results will be

mintPower: 100
numOfDays: 36

Then, you can parse the mintPower and numOfDays to excel sheet using pandas library

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.