Skip to main content
This page covers the SDK methods and contract functions used to register, link, and manage user identity data with Newton.

SDK Methods

The following methods are available on the wallet client actions extension (newtonWalletClientActions).

registerUserData

Registers KYC data for a user, scoped to your application’s identity domain. Opens the Newton identity popup to securely store the data. Signature:
registerUserData(args: {
  userData: KycUserData
  appIdentityDomain: Hex
}): Promise<unknown>
Parameters:
ParameterTypeDescription
userDataKycUserDataKYC data object from your identity vendor
appIdentityDomainHexYour identity domain as a bytes32 hex string (keccak256 of your domain string)
Example:
await walletClient.registerUserData({
  userData: kycDataFromVendor,
  appIdentityDomain: '0xabc123...', // keccak256(bytes("my.dev.domain.co"))
})

linkApp

Links a user’s registered identity to your policy client contract. The user must confirm the link in the Newton identity popup, which triggers a signed transaction from their wallet. Signature:
linkApp(args: {
  appWalletAddress: Address
  appClientAddress: Address
  appIdentityDomain: Hex
}): Promise<unknown>
Parameters:
ParameterTypeDescription
appWalletAddressAddressThe user’s dapp wallet address
appClientAddressAddressYour deployed policy client contract address
appIdentityDomainHexYour identity domain as a bytes32 hex string
Example:
await walletClient.linkApp({
  appWalletAddress: '0xUserWallet...',
  appClientAddress: '0xYourPolicyClient...',
  appIdentityDomain: '0xabc123...',
})

unlinkApp

Removes a user’s identity link from your policy client contract. Signature:
unlinkApp(args: {
  appWalletAddress: Address
  appClientAddress: Address
  appIdentityDomain: Hex
}): Promise<unknown>
Parameters:
ParameterTypeDescription
appWalletAddressAddressThe user’s dapp wallet address
appClientAddressAddressYour deployed policy client contract address
appIdentityDomainHexYour identity domain as a bytes32 hex string
Example:
await walletClient.unlinkApp({
  appWalletAddress: '0xUserWallet...',
  appClientAddress: '0xYourPolicyClient...',
  appIdentityDomain: '0xabc123...',
})

Contract Functions

linkIdentityAsUser

Called on the IdentityRegistry contract to link a user’s identity to a policy client. This is invoked under the hood when the user confirms the link via linkApp. See Contract Addresses for the IdentityRegistry address. Signature:
function linkIdentityAsUser(
    address _identityOwner,
    address _policyClient,
    bytes32[] calldata _identityDomains,
    bytes calldata _signature,
    uint256 _nonce,
    uint256 _deadline
)
Parameters: The following are the output of the link SDK method.
ParameterTypeDescription
_identityOwneraddressThe identity owner being used to authorize access to the existing identity
_policyClientaddressThe policy client where the data is to be associated
_identityDomainsbytes32[]The identity domains specifying what type of data is associated
_signaturebytesSignature by the _identityOwner to authorize the link
_nonceuint256Nonce for the signature
_deadlineuint256Deadline for the signature

Sample Policy Client

Your policy client contract must inherit both NewtonPolicyClient and EIP712. Below is a complete example:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;

import {NewtonPolicyClient} from "newton-contracts/src/mixins/NewtonPolicyClient.sol";
import {INewtonProverTaskManager} from "newton-contracts/src/interfaces/INewtonProverTaskManager.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";

contract NewtonPolicyWallet is NewtonPolicyClient, EIP712 {
    event Executed(address indexed to, uint256 value, bytes data, bytes32 taskId);
    error InvalidAttestation();
    error ExecutionFailed();

    constructor(
        address policyTaskManager,
        address owner
    ) EIP712("NewtonPolicyWallet", "1") {
        _initNewtonPolicyClient(policyTaskManager, owner);
    }

    function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
        return interfaceId == 0xdbdcaa9c || super.supportsInterface(interfaceId);
    }

    function validateAndExecuteDirect(
        address to,
        uint256 value,
        bytes calldata data,
        INewtonProverTaskManager.Task calldata task,
        INewtonProverTaskManager.TaskResponse calldata taskResponse,
        bytes calldata signatureData
    ) external returns (bytes memory) {
        require(
            _validateAttestationDirect(task, taskResponse, signatureData),
            InvalidAttestation()
        );

        (bool success, bytes memory result) = to.call{value: value}(data);
        if (!success) revert ExecutionFailed();

        emit Executed(to, value, data, task.taskId);
        return result;
    }

    receive() external payable {}
}
After deploying, register this contract with the PolicyClientRegistry. See Smart Contract Integration for instructions.

Next Steps

Identity Policy Reference

Rego built-in functions for writing identity-aware policies

Contract Addresses

IdentityRegistry and other deployed contract addresses