Skip to main content
This guide walks through the end-to-end integration of Newton Verifiable Credentials into your app. Before starting, read the overview to understand how Newton VC works.

Example Repo

Clone the repo and follow the README to run the full VC flow locally

Live Demo

Try the live demo

Prerequisites

Step 1: Write and Deploy a Policy

1a. Write your Rego 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:
See the Identity Policy Reference for all available built-in functions.

1b. Write your params_schema.json

Define the schema for your policy params, including the identity_domain:

1c. Write your policy_metadata.json

Verifiable Credential policies do not use a secrets_schema.json or policy_data_metadata.json. You only need policy_metadata.json and params_schema.json.

1d. Deploy your policy using newton-cli

Your policy directory should look like this before deploying:
Generate your policy_cids.json file with the Newton CLI command documented here. Deploy the policy contract Once you have policy_cids.json, run:
After deploying, note your policy contract address — you’ll need it in Step 2.

Step 2: Deploy a Policy Client Contract

Your policy client must inherit from both NewtonPolicyClient and EIP712. See the Reference for a complete sample contract. Key requirements:
  • Inherit NewtonPolicyClient and EIP712
  • Call _initNewtonPolicyClient(policyTaskManager, owner) in the constructor
  • Register the contract with the PolicyClientRegistry — see Smart Contract Integration
After registering, call the following on your deployed policy client contract:
  1. setPolicyAddress(policyContractAddress) — point it to the policy deployed in Step 1
  2. setPolicy(params) — set the policy params, including your identity domain:

Step 3: Collect KYC Data

Collect identity data from your users using a third-party KYC vendor. The data you receive from the vendor must map to Newton’s IdentityData fields — fields like status, birthdate, address_country_code, etc.

Step 4: Register and Confirm KYC Data

4a. Register KYC Data

Once you have the KYC data from your vendor, call registerUserData to register it with Newton, scoped to your identity domain:
When the Newton identity popup opens, Newton creates a new wallet for the user to manage their identity. The user will need to fund this wallet with ETH to continue.

4b. User Confirms KYC Data

The user sees a confirmation prompt in the Newton identity popup to verify the KYC data being registered. This is handled automatically by the popup opened in step 4a — no additional SDK calls are required. Call linkApp to link the user’s registered identity to your policy client contract:
This creates an association between the user’s Newton identity wallet and your policy client contract in the IdentityRegistry. After this link is established, Newton’s policy engine can access the user’s registered KYC data when evaluating tasks submitted through your policy client. You can find the IdentityRegistry contract address in Contract Addresses. The user completes the link confirmation in the Newton identity popup. Under the hood, this calls linkIdentityAsUser on the IdentityRegistry contract — a transaction signed by the user’s Newton identity wallet.
See SDK & Contract Reference for the full function signature and return value.

Step 6: Submit a Task

Submit a task with a signed intent from the user’s dapp wallet. The intent must be constructed and signed using the EIP712 domain of your policy client. 1. Construct the intent
2. Sign the intent using your policy client’s EIP712 domain
3. Submit for evaluation

Step 7: Execute On-Chain Transaction with Attestation

Use the attestation returned in Step 6 to execute the transaction on-chain through your policy client.
validateAndExecuteDirect verifies the attestation on-chain and executes the call — only if the policy passed.

Unlinking

To remove a user’s identity link from your app, call unlinkApp:

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