Verify
Cross Chain Transaction Verification#
This section provides guidance on verifying transactions across different blockchain chains, assuming that a side chain has already been deployed and indexed by the main chain.
Sending a Transaction#
Any transaction with the status "Mined" can be verified, provided that the transaction has been indexed.
Verifying the Transaction#
There are two scenarios for verification:
1rpc VerifyTransaction (VerifyTransactionInput) returns (google.protobuf.BoolValue) {2option (aelf.is_view) = true;3}45message VerifyTransactionInput {6aelf.Hash transaction_id = 1;7aelf.MerklePath path = 2;8int64 parent_chain_height = 3;9int32 verified_chain_id = 4;10}
The VerifyTransaction method is used for verification and returns whether the transaction was mined and indexed by the destination chain. The method is the same for both scenarios; only the input values differ.
Verifying a Main Chain Transaction#
To verify a main chain transaction on a side chain, use the VerifyTransaction method on the side chain with the following input values:
You can retrieve the Merkle path of a transaction in a block by using the chain's API method GetMerklePathByTransactionIdAsync.
Verifying a Side Chain Transaction#
For verifying a side chain transaction:
1rpc GetBoundParentChainHeightAndMerklePathByHeight (google.protobuf.Int64Value) returns (CrossChainMerkleProofContext) {2option (aelf.is_view) = true;3}45message CrossChainMerkleProofContext {6int64 bound_parent_chain_height = 1;7aelf.MerklePath merkle_path_from_parent_chain = 2;8}
Using the result from the above API, call VerifyTransaction on the target chain with:
Edited on: 18 July 2024 04:28:53 GMT+0