Reading transaction data
You can use the ZKsync CLI to fetch and display detailed information for a transaction. It can be used to check the status, amounts transferred, fees, method signatures, and arguments of transactions.
zksync-cli transaction info
If you do not pass in any options to the command, the CLI prompts you to select the chain and transaction hash.
? Chain to use ZKsync Sepolia Testnet
? Transaction hash 0x7f82dbf93281930ee01644d01a84b3f13df51d0082370298d353982f008f09e1
The CLI returns the transaction data along with the method arguments and additional details.
──────────────────── Main info ────────────────────
Transaction hash: 0x7f82dbf93281930ee01644d01a84b3f13df51d0082370298d353982f008f09e1
Status: completed
From: 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6
To: 0x927488F48ffbc32112F1fF721759649A89721F8F
Value: 0 ETH
Fee: 0.00000220235 ETH | Initial: 0.0000520258 ETH Refunded: 0.00322339725 ETH
Method: transfer(address to, uint256 amount) returns (bool) 0xa9059cbb
───────────────── Method arguments ─────────────────
[1] to (address): 0xfAa77e3314c82cD5097B80Ab42C6A3749f33dEE6
[2] amount (uint256): 1
───────────────────── Details ─────────────────────
Date: 7/23/2024, 6:58:53 PM (15 hours ago)
Block: #3515643
Nonce: 3
--abi
When ZKsync CLI reads a transaction that includes interaction with a smart contract's method, it first tries to fetch contract verification data from the server. If the contract is not verified, the CLI queries the open signature database to get the signature of the transaction method. If the CLI fails to find a matching method signature, the transaction data will be displayed as a hex string.
You can manually pass the contract ABI data manually using the --abi
option to decode the transaction's input data.
zksync-cli transaction info --abi "./Greeter.json"
--full
The --full
option will include additional details of the transaction which include the transaction status on L1.
To see an example of the full data you receive with the --full
option:
zksync-cli transaction info \
--chain "zksync-sepolia" \
--transaction "0x6fe7bcdbef11776095c7dd4283a54f51e60c0fe7cfc784fa52b9dcb8f2270f9f" \
--full
--raw
The --raw
option returns the transaction data as a raw JSON response.
To see an example of the raw JSON data:
zksync-cli transaction info \
--chain "zksync-sepolia" \
--transaction "0x6fe7bcdbef11776095c7dd4283a54f51e60c0fe7cfc784fa52b9dcb8f2270f9f" \
--raw