Kit
Type aliases

MaybeAccount

MaybeAccount<TData, TAddress> = { address: Address<TAddress>; exists: false; } | Account<TData, TAddress> & object

Represents an account that may or may not exist on-chain.

When the account exists, it is represented as an Account type with an additional exists attribute set to true. When it does not exist, it is represented by an object containing only the address of the account and an exists attribute set to false.

Type Parameters

Type ParameterDefault typeDescription
TData extends Uint8Array | object-The nature of this account's data. It can be represented as either a Uint8Array – meaning the account is encoded – or a custom data type – meaning the account is decoded.
TAddress extends stringstringSupply a string literal to define an account having a particular address.

Example

// Account exists
const myExistingAccount: MaybeAccount<MyAccountData, '1234..5678'> = {
    exists: true,
    address: address('1234..5678'),
    data: { name: 'Alice', age: 30 },
    // ...
};
 
// Account does not exist
const myMissingAccount: MaybeAccount<MyAccountData, '8765..4321'> = {
    exists: false,
    address: address('8765..4321'),
};

On this page