Purpose
The purpose of access levels is to provide a tiered approach to user verification and/or categorization before a user can receive certain assets and privileges in an application. Access levels may be defined using built-in protocol functionality or an external provider: Access levels are used with the following rules:- Maximum Account Value By Access Level Rule.
- Withdrawal Limit By Access Level.
- Account Deny For No Access Level.
- Account Max Received By Access Level.
Quick Start
Deploy the protocol and your application manager using the deployment guide. Before you start be sure that you have also registered a rule admin and assumed that the$RULE_ADMIN
private key is equivalent to $RULE_ADMIN_KEY
in the following example.
For example, we can set a rule for the user to only be able to withdraw 1000 USDC from their account once they’ve reached access level 1 using the Withdrawal Limit By Access Level rule. In order to set this up we first will call the function addAccountMaxValueOutByAccessLevel(address,uint48[])
on the protocol address using our ruleAdministrator account with the address in the function signature being the address of the application manager and the array of uints being [0, 10000000, 10000000, 10000000, 10000000].
to
and the blockNumber
fields:
ruleId
is 0 and we can pass that along to our application manager. It should be noted that if you were to run this in a smart contract script, you would just need to take the return value generated from addAccountMaxValueOutByAccessLevel
. Once we have this ruleId, we can add it to our access level using the setAccountMaxValueOutByAccessLevelId(uint32 _ruleId)
function on the application handler.