Graphite
  • Overview
    • Introduction
    • What is Graphite?
    • Connect to Graphite
    • Graphite account activation
    • Graphite Wrapped Tokens
  • Build on Graphite
    • Getting started
    • System Contracts
      • Account Activation
      • Filter Contract (KYC Transaction Filters)
      • KYC Contract
      • Reputation
    • How to Complete KYC in a Testnet
    • How to Deploy Smart Contracts Using Hardhat: A Step-by-Step Guide
    • SDK
      • JS SDK
  • Infrastructure
    • Graphite Nodes
      • Graphite testnet node setup
      • Graphite mainnet node setup
  • Ecosystem
    • Graphite Wallet
      • Graphite Web3 Documentation
    • Graphite Bridge
    • The Graphite Explorer
      • API documentation
    • Faucet Testnet
Powered by GitBook
On this page
  • Intro
  • Primary actions
  • Status of KYC
  • Corner-Cases
  • Misc
  • Network address of the contract
  • Functions
  • createKYCRequest(level, data)
  • approveKYCRequest(index)
  • declineRequest(index)
  • viewMyRequest(senderKYCIndex)
  • getLastGlobalRequestIndexOfAddress(addr)
  • viewRequestAssignedToCentre(KYCCenteraddr, localKYCIndex)
  • decreaseKYCLevel(addr, level)
  • repairLostRequest()
  • setLevelPrice(...)
  1. Build on Graphite
  2. System Contracts

KYC Contract

PreviousFilter Contract (KYC Transaction Filters)NextReputation

Last updated 6 months ago

Intro

KYCContract.sol is a Graphite system smart contract. It's needed for general users and KYC Centers to enable KYC Verification.

The KYC Verification process starts and finishes on the blockchain with function calls of this smart contract. But the KYC verification itself (information providing, verification of the authenticity) happens off-chain between a user and a KYC Center. All private data stays off-chain, only the result of the KYC verification is written on the blockchain.

Primary actions

  • As a user, to apply for KYC Verification and transfer the deposit for KYC, call createKYCRequest(level, data).

  • As a KYC Center, to approve a user's KYC request and verify KYC Level, call approveKYCRequest(index).

  • As a KYC Center, to decline a user's KYC request in case of a failed verification, call declineRequest(index).

Status of KYC

  • As a user, to view one of your KYC requests and check its status, call viewMyRequest(senderKYCIndex).

  • To get the global index of a user's last KYC request, call getLastGlobalRequestIndexOfAddress(addr).

  • To get a KYC request assigned to a KYC Center, call viewRequestAssignedToCentre(KYCCenteraddr, localKYCIndex).

Corner-Cases

  • As a user, for a pending KYC Request in which the assigned KYC Center was revoked of its role, call repairLostRequest() to withdraw the KYC request and return the deposit.

  • As a KYC Center, to revoke a user’s granted KYC Level (justification for the action required), call decreaseKYCLevel(addr, level).

Misc

  • setLevelPrice(...) is for administrative purposes and changes the deposit size needed for each KYC Level.

Network address of the contract

KYCContract_address = "0x0000000000000000000000000000000000001001"

Functions

createKYCRequest(level, data)

    createKYCRequest(uint _level, bytes32 _data)
    ⎯⎯
    _level - uint; desired KYC-Level (greater than current)
    _data - bytes32; has no use 
  • Purpose

Call createKYCRequest(level, data) to request KYC Verification of a desired level for a caller account. The requested KYC Level should be greater than the account's current KYC Level.

A successful call starts the KYC Verification process which is carried out by a randomly selected KYC Center.

  • Arguments

level - integer value; KYCLevel to be granted to a caller account upon successful KYC Verification.

data - 32 byte array; will be stored in KYCRequest object, has no meaningful use in current v. of Graphite.

  • After Execution

Successful createKYCRequest() call creates KYCRequest object holding info (user addr, KYC Level, status, KYC Center, deposit) needed for KYC-Verification and stores it on the blockchain. Instances ofKYCRequest have consecutive integer indexes starting from 0. Pending KYCRequest has status equal to 0.

This function appoints a randomly choosen KYC Center from the pool of compliant KYC Centers. The chosen KYC Center is the only one for this and related KYCRequest. Only this KYC Center has the power to then approve or decline the KYCRequest.

The verification itself is carried out off-chain by the appointed KYC Center. Upon completing it, the KYC Center calls approveKYCRequest(ind) or declineRequest(ind) functions of the KYCContract.sol (current one).

Note: Only the result of KYC Verification is written on the blockchain. All private data stays off-chain between a user and a KYC Center which follows strict data protection and governance rules.

  • Details

If a KYC Level of a function caller account is equal to or greater than the requested KYC level (level arg.), the error message You already have this KYC level will be sent and execution will be stopped.

If a caller has not finished KYCVerification, execution will be stopped with a Your previous request is still pending answer error-message. Approval or decline of an active KYCRequest is required for the creation of a new one.

If a currency fee bound to a calling transaction is less than the needed amount for the requested KYC Level, the message Provided not enough Ether. will be sent with no KYCRequest creation. The exceeding fee amount, if any, will be returned to the function caller.

The KYC Verification can only happen if there is at least one appointed KYC Center on the network. If there is none, There are no kyc centres error is thrown.

approveKYCRequest(index)

    approveKYCRequest(uint _index) 
    ⎯⎯
    _index - uint; index of KYCReqeust to be approved
    
  • Purpose

As the KYC-Center of a KYCRequest, call approveKYCRequest(ind) to approve the very KYCRequest.

  • Arguments

index - integer value; Index of KYCRequest object to be approved.

  • After Execution

Successful approveKYCRequest(index) call approves the KYCRequest under the index producing KYCLevelChanged(user, level), RequestApproved(index) events.

Function changes the status of KYCRequest to 2. Now the account in KYCRequest is officially granted the requested KYC-level.

In terms of payment, 50% of the KYCRequest deposit sum is sent to the user who created KYCRequest, the other 50% is sent to the KYC-Center responsible for approving KYCRequest (i.e. calling this function).

  • Details

Execution will only go through if approveKYCRequest(index) is called by the KYC-Center mentioned KYCRequest under index.

Only KYC-Centers can call this function; Not allowed to approve error is thrown if called by a non-KYC-Center account.

If the KYCRequest isn't pending (status != 0), the This request is not pending decision error is thrown.

declineRequest(index)

    declineRequest(uint _index) 
    ⎯⎯
    _index - uint; index of KYCReqeust to be declined
    
  • Purpose

As the KYC-Center of a KYCRequest, call declineRequest(ind) to decline the very KYCRequest.

  • Arguments

index - integer value; Index of KYCRequest object to be approved.

  • After Execution

Successful declineRequest call declines the KYCRequest under the index producing aRequestApproved(index) event.

This unction changes the status of KYCRequest to 1. The KYC-Level of the account in KYCRequest doesn't change.

In terms of payment, 50% of the KYCRequest deposit sum is sent to the KYC-Center which declined KYCRequest (i.e. called this function). The rest goes to the Graphite Foundation.

  • Details

Execution will only go through if declineRequest(index) is called by the KYC-Center mentioned KYCRequest under index.

Only KYC-Centers can call this function; Not allowed to approve error is thrown if called by a non-KYC-Center account.

For security reasons, it's technically possible to call declineRequest(index) for both pending (status = 0) and approved (status = 2) instances of KYCRequest.

viewMyRequest(senderKYCIndex)

    viewMyRequest(uint _senderKYCIndex)
    ⎯⎯
    senderKYCIndex - uint; account-specific index of KYCRequests of function caller 
    
  • Purpose

An account calls viewMyRequest(senderKYCIndex) to get its KYCRequest object under an index (account-specific).

Then, for example, a user can check a status of KYCReuqest: Pending - 0, Declined - 1, Approved - 2, Withdrawn due to loss of KYC-Center - 3.

  • Arguments

senderKYCIndex - integer value; Consecutive index (from 0) of KYCRequest objects created by function caller account. This index is account-specific. It's not the same as the general index ofKYCRequest objects mentioned elsewhere in this document.

  • After Execution

Returns a caller account's KYCRequest under an account-specific index.

  • Details

Calling with an invalid senderKYCIndex arg. (i.e. an account caller only successfully requested KYC twice; but viewMyRequest(4) is called) won't return KYCRequest object.

getLastGlobalRequestIndexOfAddress(addr)

    getLastGlobalRequestIndexOfAddress(address _addr)
    ⎯⎯
    _addr - address; wallet address of a user
    
  • Purpose

This function returns the index of the last KYCRequest created by the user under addr. Returns -1 if there were none KYCRequests for the addr.

Anyone on the network can all this function.

viewRequestAssignedToCentre(KYCCenteraddr, localKYCIndex)

    viewRequestAssignedToCentre(address _KYCCenteraddr, uint _localKYCIndex) 
    ⎯⎯
    _KYCCenteraddr - address; address of a KYC-Center
    _localKYCIndex - int; KYC-Center-specific index of assigned KYCRequest
  • Purpose

Call viewRequestAssignedToCentre(KYCCenteraddr, localKYCIndex) to get KYCRequest object that was assigned to the KYC Center(KYCCenteraddr) under an index (KYC-Center-specific localKYCIndex).

decreaseKYCLevel(addr, level)

    decreaseKYCLevel(address _addr, uint _level) 
    ⎯⎯
    _addr - address; wallet address of a user
    _level - int; desired KYC-Level (greater than current)
  • Purpose

Function decreases the KYC Level of a specified account (addr) to a specified value (level). It can only be called by a KYC-Center.

The intended purpose of this function is to decrease an account's KYC Level due to fraudulent or suspicious activities. The calling of this function by KYC Centers follows strict guidelines. A KYC Center that abuses the usage of decreaseKYCLevel() will be removed from its role.

Only decreasing a KYC Level is possible with this mechanism for security reasons.

repairLostRequest()

  • Purpose

In an event that the KYC Center assigned to a pending KYCRequest is to be removed from their KYC Center role, KYCRequest cannot be resolved in a standard way.

In this case, the user (creator of KYCRequest) can call repairLostRequest(), to withdraw KYCRequest (sets its status = 3) and return all of the KYCRequest deposit.

setLevelPrice(...)

  • Purpose

Determines the fee size needed to start verification for a certain KYC Level. Only Graphite network admins (owners of the KYCContract smart contract) can call this function.