# Watermark Upkeep

## Node Processing and Upkeep

The upkeep contract enables anyone to verify watermarked asset validity and retrieve watermark information without relying on a centralized database.

### Process Flow

1. Nodes store Merkle nodes in IPFS
2. Nodes submit Merkle root and IPFS URI to the Upkeep contract through `performUpkeep`:

```solidity
function performUpkeep(
    uint256 _chainId,
    uint256 _partitionId,
    bytes32 _merkleRoot,
    string calldata merkleTreeURI
)
```

### Verification

Watermark batches in a partition can be verified using the `verifyMerkleProof` method:

```solidity
function verifyMerkleProof(
    uint256 _chainId,
    uint256 _partitionId,
    bytes32[] calldata _proof,
    bytes32 _leaf
) external view returns (bool) {
    bytes32 merkleRoot = merkleProofs[_chainId][_partitionId].merkleRoot;
    if (merkleRoot == bytes32(0)) {
        revert InvalidPartitionId();
    }
    return MerkleProof.verify(_proof, merkleRoot, _leaf);
}
```

Parameters for verification are available in the PerformUpkeep event:

```solidity
event PerformUpkeep(
    uint256 indexed chainId,
    uint256 indexed partitionId,
    bytes32 indexed watermarkTreeRoot,
    string merkleTreeURI
);
```

The event's merkleTreeURI contains watermark hashes and IPFS links to media assets.

### Protocol Benefits

1. Multiple watermarks can be registered in a single transaction, reducing gas costs
2. Users pay appropriate fees for watermark processing
3. Creators can defer watermark fees to buyers through lazy minting


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xeal.gitbook.io/xeal/getting-started/invisible-watermarks-blockchain/watermark-upkeep.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
