Keyring Network | Docs
  • INTRODUCTION
    • About Us
    • Our Solution
    • Use Cases
  • USER GUIDE
    • 1. Choose a Policy
    • 2. Onboard
      • Keyring Connect
      • Keyring Pro
    • 3. Create a Credential
    • FAQ
      • What is my onboarding status?
      • How to manage multiple entities?
      • What is Keyring's business model?
      • How to create credentials x-chain?
  • INTEGRATION STEPS
    • 1. Create a Policy
      • Connect Policy Builder
    • 2. Integrate to User Flow
    • 3. Permission smart contracts
  • PROTOCOL GUIDE
    • Sandbox
      • Keyring Connect
      • Keyring Pro
    • Data Flow
      • Data Collected
      • Data Storage
    • Smart Contracts
  • RESOURCES
    • Links
    • Get in Touch
    • Brand Assets
    • Data Policies
  • Onboarding Requirements
    • Keyring Pro
      • FalconX
    • Keyring Connect
Powered by GitBook
On this page
  • 1. Use a test Policy
  • 2. On-chain Permissioning
  • Useful links
  • 3. Test User Flow
  1. PROTOCOL GUIDE
  2. Sandbox

Keyring Connect

PreviousSandboxNextKeyring Pro

Last updated 3 months ago

1. Use a test Policy

Use our Keyring Connect Test Policy (ID: 7 ). It includes usual data points verified by a centralised exchange. Policy setup:

  1. Data sources: Binance, Binance U.S., Kraken, Coinbase, Revolut

  2. Rule: Individual users

    • KYC is passed

    • Exclude if residence country is in

  3. Other parameters:

    • Refresh rate: 1 year

🔗 Address of the deployed Sepolia .

2. On-chain Permissioning

Hook your chosen functions with permissioning reading from the KeyringCredentialViewer, for Test Policy 7. The hook uses a view function, which maps wallet addresses to Policy IDs. Here, it will verify that a user wallet has valid credentials for Policy 7.

if(!keyring.checkCredential(policyId, msg.sender)) {
    revert Unauthorized();
}

The Keyring view function checkCredential will return a boolean value if the given address (in this case the msg.sender) is authorised or not for the given Policy ID.

Example: Uniswap v4

In our Uniswap v4 example, here are the functions we'd want to permission:

  • beforeAddLiquidity : this function is invoked whenever a user deposits one of the two supported assets (or both) in the pool and receives an LP token representing a pro-rata ownership over the pool TVL. By hooking into the preliminary step of this process, we can prevent bad actors from tainting the pool even before an actual token transfer is initiated (thus achieving max gas efficiency).

  • beforeSwap : similarly, we can block unwanted users from interacting with the pool by tapping into the swap checker hook and revert if a non-permissioned user tries to initiate a swap.


Part 1: Hook initialisation. In the specific example of Uniswap v4 Keyring hook, we are setting up a Keyring Cache instance and a single immutable PolicyID, but projects may want to have a mutable Policy ID if they wish or use multiple policies to check their users.

IKeyringCache public immutable keyringCredentialViewer;
uint256 public immutable policyId;

error Unauthorized();

constructor(IPoolManager _poolManager, address _keyring, uint256 _policyId) BaseHook(_poolManager) {
    keyringCache = IKeyringCache(_keyring);
    policyId = _policyId;
}

Part 2: Include hook in relevant functions. Code example available here:

Useful links

3. Test User Flow

Test the end-to-end user journey on the Keyring app.

You'll need Sepolia ETH to create your credentials. You can get some here:

  • Select onboarding for Policy 7 and follow the steps

  • Download the browser extension

  • Navigate to [Binance] and generate your proofs

  • Create credentials

We are not mocking accounts on data source websites. Therefore, you'll only be able to validate onboarding if you verify the requirements set out by the Policy.

🔗 deployed on Sepolia

🔗

🔗

🔗

Navigate to and test the user journey with your own Sepolia test environment:

see here
FATF blacklist
Policy Manager contract
https://github.com/Keyring-Network/keyring-integration-examples
KeyringCredentialViewer
Alchemy
Infura
Mining faucet
https://sandbox-titan.app.keyring.network/