Skip to main content
Added the CLI method utilizing Foundry cast calldata-decode command.
Source Link
SYED ASAD KAZMI
  • 5.8k
  • 2
  • 7
  • 22

Using the first 4 bytes of the hex-encoded transaction data:

0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000

i.e., 0x79fcd8ee, we can get the function signature using openchain.xyz as:

increaseSupply(address,uint256)

Using Python Script

Now, you can get the ABI of increaseSupply() function from the contract shown as "Interact with" i.e., 0xf1D2788800b3019868afe35991D360d6Ab81061c.

As, it's a proxy contract, so the ABI of the function can be fetched from the corresponding implementation contract i.e., 0xADbaB4c2967F3Cc0c29a26A4eCb576994f6389fE:

implementation contract

increaseSupply ABI

So, provided with the ABI of increaseSupply() function, here is the minimal python script utilizing web3.py library, that you can use to decode the parameters:

from web3 import Web3

rpc_url = "https://base-sepolia-rpc.publicnode.com"
web3 = Web3(Web3.HTTPProvider(rpc_url))

tx_hex_data = "0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000"

increaseSupply_abi = """[{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"increaseSupply","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]"""

gnosis_safe_contract = web3.eth.contract(abi=increaseSupply_abi)
decoded_input = gnosis_safe_contract.decode_function_input(tx_hex_data)
decoded_function = decoded_input[0]
decoded_params = decoded_input[1]

wallet = decoded_params["_wallet"]
value = decoded_params["_value"]

print("wallet:", wallet)
print("value (in Wei):", value)
print("value (in Ether):", web3.from_wei(value, 'ether'))

OUTPUT

enter image description hereOutput

Using CLI

You can use the cast calldata-decode command of Foundry:

cast calldata-decode "increaseSupply(address,uint256)" 0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000

OUTPUT

cast calldata-decode output

Using the first 4 bytes of the hex-encoded transaction data:

0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000

i.e., 0x79fcd8ee, we can get the function signature using openchain.xyz as:

increaseSupply(address,uint256)

Now, you can get the ABI of increaseSupply() function from the contract shown as "Interact with" i.e., 0xf1D2788800b3019868afe35991D360d6Ab81061c.

As, it's a proxy contract, so the ABI of the function can be fetched from the corresponding implementation contract i.e., 0xADbaB4c2967F3Cc0c29a26A4eCb576994f6389fE:

implementation contract

increaseSupply ABI

So, provided with the ABI of increaseSupply() function, here is the minimal python script utilizing web3.py library, that you can use to decode the parameters:

from web3 import Web3

rpc_url = "https://base-sepolia-rpc.publicnode.com"
web3 = Web3(Web3.HTTPProvider(rpc_url))

tx_hex_data = "0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000"

increaseSupply_abi = """[{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"increaseSupply","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]"""

gnosis_safe_contract = web3.eth.contract(abi=increaseSupply_abi)
decoded_input = gnosis_safe_contract.decode_function_input(tx_hex_data)
decoded_function = decoded_input[0]
decoded_params = decoded_input[1]

wallet = decoded_params["_wallet"]
value = decoded_params["_value"]

print("wallet:", wallet)
print("value (in Wei):", value)
print("value (in Ether):", web3.from_wei(value, 'ether'))

OUTPUT

enter image description here

Using the first 4 bytes of the hex-encoded transaction data:

0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000

i.e., 0x79fcd8ee, we can get the function signature using openchain.xyz as:

increaseSupply(address,uint256)

Using Python Script

Now, you can get the ABI of increaseSupply() function from the contract shown as "Interact with" i.e., 0xf1D2788800b3019868afe35991D360d6Ab81061c.

As, it's a proxy contract, so the ABI of the function can be fetched from the corresponding implementation contract i.e., 0xADbaB4c2967F3Cc0c29a26A4eCb576994f6389fE:

implementation contract

increaseSupply ABI

So, provided with the ABI of increaseSupply() function, here is the minimal python script utilizing web3.py library, that you can use to decode the parameters:

from web3 import Web3

rpc_url = "https://base-sepolia-rpc.publicnode.com"
web3 = Web3(Web3.HTTPProvider(rpc_url))

tx_hex_data = "0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000"

increaseSupply_abi = """[{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"increaseSupply","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]"""

gnosis_safe_contract = web3.eth.contract(abi=increaseSupply_abi)
decoded_input = gnosis_safe_contract.decode_function_input(tx_hex_data)
decoded_function = decoded_input[0]
decoded_params = decoded_input[1]

wallet = decoded_params["_wallet"]
value = decoded_params["_value"]

print("wallet:", wallet)
print("value (in Wei):", value)
print("value (in Ether):", web3.from_wei(value, 'ether'))

OUTPUT

Output

Using CLI

You can use the cast calldata-decode command of Foundry:

cast calldata-decode "increaseSupply(address,uint256)" 0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000

OUTPUT

cast calldata-decode output

Source Link
SYED ASAD KAZMI
  • 5.8k
  • 2
  • 7
  • 22

Using the first 4 bytes of the hex-encoded transaction data:

0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000

i.e., 0x79fcd8ee, we can get the function signature using openchain.xyz as:

increaseSupply(address,uint256)

Now, you can get the ABI of increaseSupply() function from the contract shown as "Interact with" i.e., 0xf1D2788800b3019868afe35991D360d6Ab81061c.

As, it's a proxy contract, so the ABI of the function can be fetched from the corresponding implementation contract i.e., 0xADbaB4c2967F3Cc0c29a26A4eCb576994f6389fE:

implementation contract

increaseSupply ABI

So, provided with the ABI of increaseSupply() function, here is the minimal python script utilizing web3.py library, that you can use to decode the parameters:

from web3 import Web3

rpc_url = "https://base-sepolia-rpc.publicnode.com"
web3 = Web3(Web3.HTTPProvider(rpc_url))

tx_hex_data = "0x79fcd8ee0000000000000000000000005f6e161db566aa8c4f3b087d17fc42e865a11d7e00000000000000000000000000000000000000000000001c30731cec03200000"

increaseSupply_abi = """[{"inputs":[{"internalType":"address","name":"_wallet","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"increaseSupply","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]"""

gnosis_safe_contract = web3.eth.contract(abi=increaseSupply_abi)
decoded_input = gnosis_safe_contract.decode_function_input(tx_hex_data)
decoded_function = decoded_input[0]
decoded_params = decoded_input[1]

wallet = decoded_params["_wallet"]
value = decoded_params["_value"]

print("wallet:", wallet)
print("value (in Wei):", value)
print("value (in Ether):", web3.from_wei(value, 'ether'))

OUTPUT

enter image description here