> For the complete documentation index, see [llms.txt](https://xeal.gitbook.io/xeal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xeal.gitbook.io/xeal/getting-started/invisible-watermarks-blockchain/watermark-upkeep.md).

# 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
