Access Keys
Full access keys.
Grant complete control over an account, allowing the holder to per- form any operation on behalf of the account. These keys are typically used by account owners or trusted entities requiring full control over the associated account.
Function call keys(limited access keys).
Grant permissions for specific actions or function calls within a smart contract. This key type is commonly used for the delegation of specific tasks to trusted third-party contracts or for executing specific actions without granting full account access.
The account owner may designate a specific access key to manage the account's resources. A locked account requires the usage of a specific access key for any transaction or operation to be executed successfully. This provides an additional layer of security because even if an attacker gains access to other access keys associated with the account, they cannot perform any operation without the designated access key.
#![allow(unused)] fn main() { // Create a full access key #[near_bindgen] pub fn create_full_access_key(&mut self, public_key: PublicKey) { self.env().key_create( public_key, &access_key::AccessKey { nonce: 0, permission: access_key::Permission::FullAccess, }, ); } // Create a function call key #[near_bindgen] pub fn create_function_call_key(&mut self, public_key: PublicKey) { self.env().key_create( public_key, &access_key::AccessKey { nonce: 0, permission: access_key::Permission::FunctionCall { allowance: access_key::FunctionCallPermission { allowance: 10.into(), // Maximum number of function call allowances receiver_id: "receiver_account".to_string(), method_names: vec!["allowed_method".to_string()], }, }, }, ); } }