Skip to main content

Access Keys

The RPC API enables you to retrieve information about an account's access keys. Access keys are cryptographic keys that allow actions to be performed on behalf of an account, with different permission levels for security.

Access Key Types

  • Full Access Keys: Can perform any action on the account, including deploying contracts, managing other keys, and transferring funds
  • Function Call Keys: Restricted to calling specific contract methods with limited allowance for gas fees

Quick Reference

MethodEndpointPurpose
view_access_keyQuery single keyGet details of a specific access key
view_access_key_listQuery all keysList all access keys for an account
single_access_key_changesTrack specific changesMonitor changes to specific keys
all_access_key_changesTrack all changesMonitor all key changes for accounts

View access key

Description

Returns information about a single access key for a given account.

If permission of the key is FunctionCall, it will return more details such as the allowance, receiver_id, and method_names.

  • method: query
  • params:
    • request_type: view_access_key
    • finality OR block_id
    • account_id: "example.testnet"
    • public_key: "ed25519:..."

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "query",
"params": {
"request_type": "view_access_key",
"finality": "final",
"account_id": "account.rpc-examples.testnet",
"public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd"
}
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"block_hash": "J1zkrK8sHuzzV8pkXsEPrZH7SQZeJ2NSEs9L1hSWzVgg",
"block_height": 187316844,
"nonce": 187309654000001,
"permission": {
"FunctionCall": {
"allowance": "149788200694421800000000",
"method_names": [
"write_record",
"get_record",
"get_greeting",
"__contract_abi",
"contract_source_metadata"
],
"receiver_id": "contract.rpc-examples.testnet"
}
}
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


View access key list

Description

Returns all access keys for a given account.

  • method: query
  • params:
    • request_type: view_access_key_list
    • finality OR block_id
    • account_id: "example.testnet"

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "query",
"params": {
"request_type": "view_access_key_list",
"finality": "final",
"account_id": "account.rpc-examples.testnet"
}
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"block_hash": "29G6xeV4ufkVsY24YZPfiRwLMTNoKrAMitrjg6nvVZqq",
"block_height": 187319080,
"keys": [
{
"access_key": {
"nonce": 187309654000000,
"permission": "FullAccess"
},
"public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
},
{
"access_key": {
"nonce": 187309654000001,
"permission": {
"FunctionCall": {
"allowance": "149788200694421800000000",
"method_names": [
"write_record",
"get_record",
"get_greeting",
"__contract_abi",
"contract_source_metadata"
],
"receiver_id": "contract.rpc-examples.testnet"
}
}
},
"public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd"
}
]
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


View access key changes (single)

Description

Returns individual access key changes in a specific block. You can query multiple keys by passing an array of objects containing the account_id and public_key.

  • method: changes
  • params:
    • changes_type: single_access_key_changes
    • keys: [{ account_id, public_key }]
    • finality OR block_id

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "changes",
"params": {
"changes_type": "single_access_key_changes",
"keys": [
{
"account_id": "account.rpc-examples.testnet",
"public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd"
}
],
"block_id": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w"
}
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"block_hash": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w",
"changes": [
{
"cause": {
"tx_hash": "J3KbUXF9YPu2eGnbDCACxGvmMDZMdP7acGYhVLHGu9y2",
"type": "transaction_processing"
},
"change": {
"access_key": {
"nonce": 187309654000001,
"permission": {
"FunctionCall": {
"allowance": "142924791772640836536480",
"method_names": [
"write_record",
"get_record",
"get_greeting",
"__contract_abi",
"contract_source_metadata"
],
"receiver_id": "contract.rpc-examples.testnet"
}
}
},
"account_id": "account.rpc-examples.testnet",
"public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd"
},
"type": "access_key_update"
}
]
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


View access key changes (all)

Description

Returns changes to all access keys of a specific block. Multiple accounts can be queried by passing an array of account_ids.

  • method: changes
  • params:
    • changes_type: all_access_key_changes
    • account_ids: [ "example.testnet", "example2.testnet"]
    • finality OR block_id

Example

{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "changes",
"params": {
"changes_type": "all_access_key_changes",
"account_ids": ["account.rpc-examples.testnet"],
"block_id": 187309655
}
}
Example response:
{
"jsonrpc": "2.0",
"result": {
"block_hash": "6EDgS3zF9aoBMfdHqthQTQtudt7JzdLBbkTb6Jn4wfP9",
"changes": [
{
"cause": {
"receipt_hash": "9meU2ibDyJS2ga4se7j5knsWetKrXaw5qBpwrYgN1Qeh",
"type": "receipt_processing"
},
"change": {
"access_key": {
"nonce": 187309654000000,
"permission": "FullAccess"
},
"account_id": "account.rpc-examples.testnet",
"public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M"
},
"type": "access_key_update"
},
{
"cause": {
"receipt_hash": "9meU2ibDyJS2ga4se7j5knsWetKrXaw5qBpwrYgN1Qeh",
"type": "receipt_processing"
},
"change": {
"access_key": {
"nonce": 187309654000000,
"permission": {
"FunctionCall": {
"allowance": "150000000000000000000000",
"method_names": [
"write_record",
"get_record",
"get_greeting",
"__contract_abi",
"contract_source_metadata"
],
"receiver_id": "contract.rpc-examples.testnet"
}
}
},
"account_id": "account.rpc-examples.testnet",
"public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd"
},
"type": "access_key_update"
}
]
},
"id": "dontcare"
}
Error handling:

When making RPC API requests, you may encounter various errors related to network configuration, rate limiting, or request formatting. For comprehensive information about error types, causes, and solutions, see the RPC Errors documentation.


Best Practices

  • Use specific queries: Use view_access_key when you know the exact key instead of listing all keys
  • Cache results: Access key information does not change frequently, consider caching
  • Batch operations: When checking multiple keys, use single_access_key_changes with multiple keys
  • Archival nodes: Only use archival endpoints when historical data is required