Skip to main content

Accounts

Accounts are the data and state storage mechanism for BBAChain.

Overview

In BBAChain, accounts are used to store data and state. Every account has an owner program that controls how the account's data can be modified.

Account Structure

An account contains:

  • Daltons: The account's balance in daltons (1 BBA = 1,000,000,000 daltons)
  • Data: A byte array of arbitrary data
  • Owner: The program that owns the account
  • Executable: Whether the account is an executable program
  • Rent Epoch: The epoch at which the account will next owe rent

Account Types

System Accounts

System accounts are owned by the System Program and are used for basic operations like transferring BBA.

Program Accounts

Program accounts are owned by executable programs and contain program-specific data.

Data Accounts

Data accounts store application state and are owned by programs.

Account Ownership

Accounts are owned by programs. The owner program has exclusive rights to:

  • Modify the account's data
  • Assign ownership to another program
  • Decrease the account's daltons

Rent

Accounts in BBAChain must maintain a minimum balance to remain exempt from rent collection. Accounts that don't meet the minimum balance are subject to rent collection.

Example

import { Connection, PublicKey } from "@bbachain/web3.js";

const connection = new Connection("https://api-mainnet.bbachain.com");
const accountPubkey = new PublicKey("...");

const accountInfo = await connection.getAccountInfo(accountPubkey);
console.log("Owner:", accountInfo.owner.toBase58());
console.log("Daltons:", accountInfo.daltons);
console.log("Data:", accountInfo.data);

Next Steps