Prerequisites
| Requirement | Details |
|---|---|
| Newton SDK | @magicnewton/newton-protocol-sdk installed and configured |
| Newton API key | Create one in the dashboard |
| Policy client contract | Must inherit NewtonPolicyClient + EIP712 and be registered with PolicyClientRegistry |
| Identity domain | A bytes32 string (keccak256 of your domain, e.g. keccak256(bytes("my.dev.domain.co"))) |
| KYC vendor | A third-party vendor to collect user identity data |
Step 1: Write and Deploy a Policy
Write a Rego policy that uses Newton identity built-in functions. For example, to enforce that a user is approved and at least 18 years old:The
identity_domain value is the keccak256 hash of your domain string encoded as a bytes32 hex value. For example: keccak256(bytes("my.dev.domain.co")). This scopes the identity data to your application. An example value of this is 0x70013f8147873660b512807fffa46355f43463c571a0b05eea4ede282dfcf523Step 2: Deploy a Policy Client Contract
Your policy client must inherit from bothNewtonPolicyClient and EIP712. See the Reference for a complete sample contract.
Key requirements:
- Inherit
NewtonPolicyClientandEIP712 - Call
_initNewtonPolicyClient(policyTaskManager, owner)in the constructor - Register the contract with the
PolicyClientRegistry— see Smart Contract Integration
Step 3: Collect KYC Data
Collect identity data from your users using a third-party KYC vendor. The structure of this data maps to the fields Newton’s identity policy engine reads (see IdentityData fields).Step 4: Register KYC Data
Once you have the KYC data, callregisterUserData to register it with Newton, scoped to your identity domain:
Step 5: User Confirms KYC Data
The user sees a confirmation prompt in the Newton identity flow to verify the KYC data being registered. This is handled by the popup opened in Step 4.Step 6: Link User Identity to Your App
CalllinkApp to link the user’s registered identity to your policy client contract:
Step 7: User Confirms the Link
The user completes the link confirmation in the Newton identity popup. Under the hood, this callslinkIdentityAsUser on the IdentityRegistry contract — a transaction signed by the user’s wallet.
See SDK & Contract Reference for the full contract function signature.
Step 8: Submit a Task
Submit a task with a signed intent from the user’s dapp wallet (the same wallet that confirmed the link in Step 7). The intent must be signed using the EIP712 domain of your policy client:Unlinking
To remove a user’s identity link from your app, callunlinkApp:
Reference Pages
SDK & Contract Reference
Full SDK method signatures and contract functions
Identity Policy Reference
All Rego built-in functions for identity checks
Have questions?
Get in touch with someone from the Newton team to discuss your integration