Smart Contracts
Integrating Predicate on the smart contract level ensures no transaction is processed without a direct compliance attestation.1
Select integration pattern
Based off your application, choose between two smart contract integration patterns
2
Make the code changes
While every application is different, you will find an example contract integration below
3
Deploy your contract
Optionally, modify existing deployment scripts to include the addition of new state variables (PolicyID string and ServiceManager address)
Mental model
- Predicated functions on your contract require a
PredicateMessage
, an attestation produced by the PredicateAPI. - The contract, via
PredicateClient
, verifies the attestation onchain before executing business logic. - If the message is valid and unexpired for the exact call, execution proceeds; otherwise the transaction reverts.
Integration Pattern
There are two recommended integration patterns.Both integration patterns leverage
PredicateClient.sol
, an audited, OpenZeppelin-namespaced smart contract we provide to simplify onchain integration.Recommended when users don’t originally directly interact with your smart contract (e.g., Uniswap V4 hooks, batch transactions).
Your application contract inherits the PredicateClient contract directly allowing you to enforce attestations directly.
This is the simplest integration as no additional smart contract deployment is required.Application Contract ExampleYou will need to implement the setPolicy and setPredicateManager functions, which we recommend you make ownable.
Example Contract Direct Inheritance Pattern
Deploying the contracts
Update your deployment script to include the following constructor arguments:_predicateManager
: The ServiceManager address for your target chain. See Supported Chains._policyID
: The policy identifier. For initial testing, you may usex-test-random
, which returns a compliant response approximately 50% of the time. You will update this value in step two.
Next Step: After deploying your contracts, proceed to Application Onboarding to configure your organization and policies.