accounts

SystemService::Accounts

struct SystemService::Accounts {
    const psibase::AccountNumber service;       // "accounts"
    const psibase::AccountNumber inviteService; // "invite"
    const psibase::AccountNumber nullAccount;   // AccountNumber 0 is reserved for the null account

    init(...);        // Only called once during chain initialization
    newAccount(...);  // Used to create a new account with a specified auth service
    setAuthServ(...); // Used to update the auth service used by an account
    exists(...);      // Return value indicates whether the account `name` exists
    billCpu(...);     // Reduces the account balance. Aborts the transaction if the account does not have sufficient resources.
};

This service facilitates the creation of new accounts.

Only the Accounts service itself and the inviteService may create new accounts. Other services may also use this service to check if an account exists.

SystemService::Accounts::init

void SystemService::Accounts::init();

Only called once during chain initialization.

Creates accounts for other system services.

SystemService::Accounts::newAccount

void SystemService::Accounts::newAccount(
    psibase::AccountNumber name,
    psibase::AccountNumber authService,
    bool                   requireNew
);

Used to create a new account with a specified auth service.

The accounts permitted to call this action are restricted to either Accounts itself or the service indicated by inviteService. If the requireNew flag is set, then the action will fail if the name account already exists.

SystemService::Accounts::setAuthServ

void SystemService::Accounts::setAuthServ(
    psibase::AccountNumber authService
);

Used to update the auth service used by an account.

SystemService::Accounts::exists

bool SystemService::Accounts::exists(
    psibase::AccountNumber name
);

Return value indicates whether the account name exists.

SystemService::Accounts::billCpu

void SystemService::Accounts::billCpu(
    psibase::AccountNumber   name,
    std::chrono::nanoseconds amount
);

Reduces the account balance. Aborts the transaction if the account does not have sufficient resources..

SystemService::AccountsStatus

struct SystemService::AccountsStatus {
    uint32_t totalAccounts; 

    key(...); 
};

Shows statistics accross accounts.

totalAccounts holds the total number of accounts on chain

SystemService::AccountsStatus::key

std::tuple<> SystemService::AccountsStatus::key() const;

SystemService::Account

struct SystemService::Account {
    psibase::AccountNumber       accountNum;      
    psibase::AccountNumber       authService;     
    std::optional<ResourceLimit> resourceBalance; 

    key(...); 
};

Structure of an account.

accountNum is the name of the account authService is the service used to verify the transaction claims when accountNum is the sender resourceBalance is the available resources for the account

SystemService::Account::key

psibase::AccountNumber SystemService::Account::key() const;