Module IAccountKeychain
Expand description
Account Keychain interface for managing authorized keys
This precompile allows accounts to authorize secondary keys with:
- Different signature types (secp256k1, P256, WebAuthn)
- Expiry times for key rotation
- Per-token spending limits for security
Only the main account key can authorize/revoke keys, while secondary keys can be used for regular transactions within their spending limits.
interface IAccountKeychain {
enum SignatureType { Secp256k1, P256, WebAuthn }
struct TokenLimit { address token; uint256 amount; }
struct KeyInfo { SignatureType signatureType; address keyId; uint64 expiry; bool enforceLimits; bool isRevoked; }
event KeyAuthorized(address indexed account, bytes32 indexed publicKey, uint8 signatureType, uint64 expiry);
event KeyRevoked(address indexed account, bytes32 indexed publicKey);
event SpendingLimitUpdated(address indexed account, bytes32 indexed publicKey, address indexed token, uint256 newLimit);
function authorizeKey(address keyId, SignatureType signatureType, uint64 expiry, bool enforceLimits, TokenLimit[] calldata limits) external;
function revokeKey(address keyId) external;
function updateSpendingLimit(address keyId, address token, uint256 newLimit) external;
function getKey(address account, address keyId) external view returns (KeyInfo memory);
function getRemainingLimit(address account, address keyId, address token) external view returns (uint256);
function getTransactionKey() external view returns (address);
error UnauthorizedCaller();
error KeyAlreadyExists();
error KeyNotFound();
error KeyExpired();
error SpendingLimitExceeded();
error InvalidSignatureType();
error ZeroPublicKey();
error ExpiryInPast();
error KeyAlreadyRevoked();
}Structs§
- Expiry
InPast - Custom error with signature
ExpiryInPast()and selector0x79955a10. - IAccount
Keychain Instance - A
IAccountKeychaininstance. - Invalid
Signature Type - Custom error with signature
InvalidSignatureType()and selector0x60cd402d. - KeyAlready
Exists - Custom error with signature
KeyAlreadyExists()and selector0xaa1ba2f8. - KeyAlready
Revoked - Custom error with signature
KeyAlreadyRevoked()and selector0xcdf0b34f. - KeyAuthorized
- Emitted when a new key is authorized
Event with signature
KeyAuthorized(address,bytes32,uint8,uint64)and selector0xd53a4005b3f15b2d70588c3eee78b2a6aa8df4c3129159eedd4db416c33da194. - KeyExpired
- Custom error with signature
KeyExpired()and selector0x2572e3a9. - KeyInfo
- Key information structure
- KeyNot
Found - Custom error with signature
KeyNotFound()and selector0x5f3f479c. - KeyRevoked
- Emitted when a key is revoked
Event with signature
KeyRevoked(address,bytes32)and selector0xa97703d8de1d538ac2ccf4453e57ec2aa4ab8b29c9a57f2a6e70a9d0e268f802. - Spending
Limit Exceeded - Custom error with signature
SpendingLimitExceeded()and selector0x8a9e71ea. - Spending
Limit Updated - Emitted when a spending limit is updated
Event with signature
SpendingLimitUpdated(address,bytes32,address,uint256)and selector0x57ce4c71f9009813973686090d962422a51c0ce446502ff69c1e339b7fef40c6. - Token
Limit - Token spending limit structure
- Unauthorized
Caller - Custom error with signature
UnauthorizedCaller()and selector0x5c427cd9. - Zero
Public Key - Custom error with signature
ZeroPublicKey()and selector0xb1eddc82. - authorize
KeyCall - Authorize a new key for the caller’s account
@param keyId The key identifier (address derived from public key)
@param signatureType 0: secp256k1, 1: P256, 2: WebAuthn
@param expiry Block timestamp when the key expires (u64::MAX for never expires)
@param enforceLimits Whether to enforce spending limits for this key
@param limits Initial spending limits for tokens (only used if enforceLimits is true)
Function with signature
authorizeKey(address,uint8,uint64,bool,(address,uint256)[])and selector0x54063a55. - authorize
KeyReturn - Authorize a new key for the caller’s account
@param keyId The key identifier (address derived from public key)
@param signatureType 0: secp256k1, 1: P256, 2: WebAuthn
@param expiry Block timestamp when the key expires (u64::MAX for never expires)
@param enforceLimits Whether to enforce spending limits for this key
@param limits Initial spending limits for tokens (only used if enforceLimits is true)
Container type for the return parameters of the
authorizeKey(address,uint8,uint64,bool,(address,uint256)[])function. - getKey
Call - Get key information
@param account The account address
@param publicKey The public key
@return Key information
Function with signature
getKey(address,address)and selector0xbc298553. - getKey
Return - Get key information
@param account The account address
@param publicKey The public key
@return Key information
Container type for the return parameters of the
getKey(address,address)function. - getRemaining
Limit Call - Get remaining spending limit
@param account The account address
@param publicKey The public key
@param token The token address
@return Remaining spending amount
Function with signature
getRemainingLimit(address,address,address)and selector0x63b4290d. - getRemaining
Limit Return - Get remaining spending limit
@param account The account address
@param publicKey The public key
@param token The token address
@return Remaining spending amount
Container type for the return parameters of the
getRemainingLimit(address,address,address)function. - getTransaction
KeyCall - Get the key used in the current transaction
@return The keyId used in the current transaction
Function with signature
getTransactionKey()and selector0xb07fbc1a. - getTransaction
KeyReturn - Get the key used in the current transaction
@return The keyId used in the current transaction
Container type for the return parameters of the
getTransactionKey()function. - revoke
KeyCall - Revoke an authorized key
@param publicKey The public key to revoke
Function with signature
revokeKey(address)and selector0x5ae7ab32. - revoke
KeyReturn - Revoke an authorized key
@param publicKey The public key to revoke
Container type for the return parameters of the
revokeKey(address)function. - update
Spending Limit Call - Update spending limit for a key-token pair
@param publicKey The public key
@param token The token address
@param newLimit The new spending limit
Function with signature
updateSpendingLimit(address,address,uint256)and selector0xcbbb4480. - update
Spending Limit Return - Update spending limit for a key-token pair
@param publicKey The public key
@param token The token address
@param newLimit The new spending limit
Container type for the return parameters of the
updateSpendingLimit(address,address,uint256)function.
Enums§
- IAccount
Keychain Calls - Container for all the
IAccountKeychainfunction calls. - IAccount
Keychain Errors - Container for all the
IAccountKeychaincustom errors. - IAccount
Keychain Events - Container for all the
IAccountKeychainevents. - Signature
Type
Functions§
- new
- Creates a new wrapper around an on-chain
IAccountKeychaincontract instance.