AccountContract class

AccountContract — the reusable on-chain account primitive (packages/account).

An owner has one canonical AccountWrapper, a derived object of the account registry, so its id is computable off-chain (no read). The wrapper holds an Account whose custody balances apps deposit into and withdraw from; app-specific data hangs off it under an app-keyed slot. Authority is a hot-potato Auth minted from the tx sender and consumed by the very next account-loading call.

Constructors

AccountContract(AccountConfig _config)
config carries the deployed ids of the shared account package.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

balance({required String owner, required String coinType}) → TransactionResult Function(Transaction)
Read an owner's stored custody balance for a coin type: chains load_account(wrapper) → balance<T>(account, root, clock). Compose in a dev-inspect/simulate PTB and read the u64 return of the LAST command.
createAccount() → void Function(Transaction)
Create the sender's canonical account wrapper and share it. new derives the wrapper at its deterministic address (see deriveAccountWrapperId) and aborts if it already exists; share publishes the shared object apps borrow against.
createAccountAndDeposit({required dynamic coin, required String coinType}) → void Function(Transaction)
First-time funding in ONE PTB: create the sender's wrapper, deposit coin through the fresh handle, then share LAST (once shared, by-value use of the handle is over). This cannot be split into createAccount + depositFunds: an object input can only address an object that pre-exists the PTB, so a wrapper created inside it is reachable only through new's result handle.
depositFunds({required String wrapperId, required dynamic coin, required String coinType}) → void Function(Transaction)
Deposit a caller-provided coin into the account's stored balance via the PTB-callable deposit_funds (folds settle → authorize → load → deposit; clock and accumulator root auto-injected). The caller owns coin sourcing.
deriveAccountWrapperId(String owner) → String
The deterministic id of an owner's canonical account wrapper — no chain read needed. The wrapper is a derived object of the account registry, so its id is derive_address(registry, AccountWrapperKey(owner)).
generateAuth() → TransactionResult Function(Transaction)
Mint owner authority for the transaction sender. A hot-potato Auth consumed by the very next account-loading call (load_account_mut inside deposit_funds / withdraw_funds / an app's own entrypoints).
loadAccount({required String wrapperId}) → TransactionResult Function(Transaction)
Borrow the Account out of its wrapper — the read-side entry point apps chain their own getters onto (account::balance<T>, an app's own data accessors).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
withdrawFunds({required String wrapperId, required BigInt amount, required String coinType}) → TransactionResult Function(Transaction)
Withdraw amount (raw u64 units) from the account's stored balance via the PTB-callable withdraw_funds (folds settle → authorize → load → withdraw; clock and accumulator root auto-injected), returning the minted Coin<T> for the caller to transfer or compose.

Operators

operator ==(Object other) → bool
The equality operator.
inherited