Offchain Service Integration
For this walkthrough, we’ll use a web application as an example, though most other services require only a subset of these steps.1
Backend Integration
Fetching Predicate Attestations requires an API key that must be secured. Using a passthrough proxy is best practice!
2
Frontend Integration
Embed the Predicate Attestation into the transaction object, allowing users to self-authorize onchain.
Mental model
- With specific transaction information, your backend requests the PredicateAPI for an attestation.
- The PredicateAPI returns a message detailing if the request is compliant and a corresponding attestation.
- Your frontend includes that message when calling a predicated contract function.
Backend Integration
Since you’ll be serving a UI to end users, we recommend storing the API key and making Predicate API calls on your backend service:Example Backend Proxy
Frontend Integration
Use our SDK to nest the attestation details into the transaction object before the user is prompted to sign:Frontend Implementation Snippet
Understanding Predicate Functions
In both integration patterns, you’ll have a Predicated Function on your smart contract - this is the function that requires a ‘Predicate Message’ Attestation in order to be invoked. You can see this commented in the Complete Integration ExampleComplete Integration Example
Complete Integration Example
Complete Integration Example