Skip to main content

Prove API

Prover Contract

Overview

We deploy a contract known as the CrossL2Prover (contract info), taking inspiration from Superchain interop's CrossL2Inbox. Since we strongly believe in on-chain proofs, we have modified some methods to validate receipts and logs for v0.

We plan to support more claims like validateStorage or validateSrcHeader as well as more methods like executeMessage that will send the safe payload to a defined address.

Current Capabilities:

  • Store Polymer Hub state: Stores the latest app-hashes of the Polymer hub in a mapping against its block height. These app-hashes are what payloads are validated against.
  • Expose validation methods: As an application, you can call pre-defined methods with API inputs in order to validate a payload and receive a boolean result.

Methods

For applications validating specific events emitted by their contracts on a given origin chain, these methods provide a straightforward, plug-and-play solution. Validate any event with a single call.

  1. validateEvent

Validates a cross-chain event from a counterparty chain and returns the event along with event identifiers. The function will revert if the validation fails.

validateEvent(uint256 ,logIndex, bytes calldata proof) returns (bytes32 chainId, address emittingContract, bytes[] memory topics, bytes memory unindexedData)
InputsDescription
logIndexThe index of the event in the logs array of the receipt. NOTE: This is not the log index within the block, only the log index within the receipt.
proofThe proof provided by Polymer's Proof API. This is an opaque byte object constructed via ABI encoding the fields of the EventProof struct.
ReturnsDescription
chainIdChain ID of the emitting chain. (identifier)
emittingContractThe contract which emitted the event. (identifier)
topicsThe topics array from the emitted event i.e. indexed data.
unindexedDataThe ABI-encoded event data for the matched log i.e. unindexed data.

More Advanced Methods (optional)

For applications building advanced systems, such as batching multiple logs under a single receipt, these methods offer all the foundational tools needed to validate receipts and parse them for event data access. This approach optimizes proving costs by allowing developers to validate a single receipt and then iterate through and process each log independently, enhancing efficiency.

  1. validateReceipt

Validates a cross-chain receipt from a counterparty chain. The function will revert if the validation fails.

validateReceipt(bytes calldata proof) public view returns (bytes32 chainID, bytes memory rlpEncodedBytes)

InputsDescription
proofThis is returned from Polymer's proof API. This is generally an opaque bytes object but it is constructed through ABI encoding the proof fields from the above EventProof struct in this interface.
ReturnsDescription
chainIdChain ID of the emitting chain. (identifier)
rlpEncodedBytesThe raw RLP encoded bytes of the whole receipt object we are trying to prove, this is the value stored in the MMPT.

  1. parseLog

A utility function for parsing log data from a receipt given an logIndex (within the transaction).

parseLog(uint256 logIndex, bytes calldata rlpEncodedBytes) returns (address emittingContract, bytes[] memory topics, bytes memory unindexedData)

InputsDescription
logIndexThe index of the event in the logs array of the receipt. NOTE: This is not the log index within the block, only the log index within the receipt.
proofThis is returned from Polymer's proof API. This is generally an opaque bytes object but it is constructed through ABI encoding the proof fields from the above EventProof struct in this interface.
ReturnsDescription
emittingContractThe contract which emitted the event. (identifier)
topicsThe topics array from the emitted event i.e. indexed data.
unindexedDataThe ABI-encoded event data for the matched log i.e. unindexed data.