Skip to main content
Onchain enforcement requires users to submit valid attestations to your smart contract. The contract verifies the attestation before executing protected business logic.
1

Deploy your contract

Inherit from PredicateClient and set your verification_hash as the policyID.
2

Add contract to dashboard

Register your contract address in the dashboard to link it to your project.

Installation

npm i @predicate/contracts

Choose Your Client

ClientUse Case
BasicPredicateClientWho-based policies: AML/KYC, allowlist/denylist, geo-restrictions
PredicateClientPolicies that validate function calls, parameters, or value-based limits
Both clients use ERC-7201 namespaced storage for upgrade safety and are audited.

Example Contract

Set your verification_hash from the dashboard as the policyID when deploying.
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {BasicPredicateClient} from "@predicate/contracts/src/mixins/BasicPredicateClient.sol";
import {Attestation} from "@predicate/contracts/src/interfaces/IPredicateRegistry.sol";

contract Vault is BasicPredicateClient, Ownable {
    mapping(address => uint256) public balances;

    constructor(
        address _owner,
        address _registry,
        string memory _policyID  // Use your verification_hash here
    ) Ownable(_owner) {
        _initPredicateClient(_registry, _policyID);
    }

    function deposit(Attestation calldata _attestation) external payable {
        require(_authorizeTransaction(_attestation, msg.sender), "Unauthorized");
        balances[msg.sender] += msg.value;
    }

    function setPolicyID(string memory _policyID) external onlyOwner {
        _setPolicyID(_policyID);
    }

    function setRegistry(address _registry) external onlyOwner {
        _setRegistry(_registry);
    }
}

Constructor Parameters

ParameterDescription
_registryPredicate Registry address for your chain. See Supported Blockchains.
_policyIDYour verification_hash from the dashboard

Add Contract to Dashboard

After deploying, add your contract address to your project in the dashboard. This links your contract to your policy configuration.

Next Steps

Continue to Onchain Integration to update your offchain code.