Full-Access Keys and Function-Call Keys.
Full-Access Keys are the traditional type of key you might be used to, which provide complete control over an account, allowing the holder to perform any action, including transferring funds, deploying contracts, and managing other keys.
On the other hand, Function Call Keys allows you to provide restricted access to third parties. This key type, unique to NEAR, enables several use-cases worth discussing.
Let’s explore some of the main benefits of Function-Call Keys.
Enhancing User Experience
The most common use case forFunction-Call keys is to allow an application to sign transactions on the user’s behalf.
Imagine you are developing a game that records the user’s score on a smart contract. On other chains, you would have to disrupt the user’s experience to request transaction signatures each time the game needs to update the score.
With NEAR, you can request the user to generate a Function-Call key for the game’s contract and share it with the game. This way, the game can sign transactions in the user’s name, eliminating gameplay interruptions.
Sharing this key is safe for the user, because even in the case of somebody stealing it, they would only be able to call the score-keeping method, and nothing else.
Simple Onboarding
Another common use-case ofFunction-Call keys is to simplify the onboarding process for new users.
It works as follows:
-
Create a contract that has a method called
create_account- This method should only be callable by the contract itself and
- When executed, the method should create a new account and transfer some tokens to it
-
Add multiple
Function Call Keysin the contract’s account, that only allow to callcreate_account - Give these keys to your friends! They will be able to call the method, and easily create an account with some tokens
create_account method.