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)
-
configcarries the deployed ids of the sharedaccountpackage.
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.
newderives the wrapper at its deterministic address (see deriveAccountWrapperId) and aborts if it already exists;sharepublishes 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
cointhrough the fresh handle, thenshareLAST (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 throughnew's result handle. -
depositFunds(
{required String wrapperId, required dynamic coin, required String coinType}) → void Function(Transaction) -
Deposit a caller-provided
coininto the account's stored balance via the PTB-callabledeposit_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
Authconsumed by the very next account-loading call (load_account_mutinsidedeposit_funds/withdraw_funds/ an app's own entrypoints). -
loadAccount(
{required String wrapperId}) → TransactionResult Function(Transaction) -
Borrow the
Accountout 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-callablewithdraw_funds(folds settle → authorize → load → withdraw; clock and accumulator root auto-injected), returning the mintedCoin<T>for the caller to transfer or compose.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited