Documentation
    Preparing search index...

    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.

    Index
    • Parameters

      • params: { coinType: string; owner: string }

        Owner address and coin type

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      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.

    • Returns (tx: Transaction) => void

      A function that takes a Transaction object

      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.

    • Parameters

      Returns (tx: Transaction) => void

      A function that takes a Transaction object

      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.

    • Parameters

      • params: { coin: TransactionObjectArgument; coinType: string; wrapperId: string }

        Wrapper id, coin to deposit, and its coin type

      Returns (tx: Transaction) => void

      A function that takes a Transaction object

      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.

    • Parameters

      • owner: string

        Owner address

      Returns string

      The wrapper object id

      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)).

    • Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      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).

    • Parameters

      • params: { wrapperId: string }

        Wrapper id

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object and returns the Account

      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).

    • Parameters

      • params: {
            coin: string | TransactionObjectArgument;
            coinType: string;
            wrapperId: string;
        }

        Wrapper id, the received coin's object id (or a Receiving input), and its coin type

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      Move a Coin<T> that was transferred to an account's wrapper address into the account's stored balance (receive_coin). Permissionless: anyone may submit it, and value only enters the account the coin was addressed to. A sender that can only transfer a coin to an address (a bridge mint, for example) sends it to deriveAccountWrapperId(owner). The coin can arrive before the account exists and waits there until the owner creates it.

      if the config has no accountPackageIdLatest, i.e. the network still runs account v1

    • Parameters

      • params: {
            coin: string | TransactionObjectArgument;
            coinType: string;
            wrapperId: string;
        }

        Wrapper id, the received coin's object id (or a Receiving input), and its coin type

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      receiveCoin for a coin sent to the account's canonical ID (account_id, the address account_registry::derived_address returns) instead of its wrapper address. A Receiving input can't name its owner, so pick the call from where the coin sits: the wrong one aborts EUnableToReceiveObject. Senders should use the wrapper address.

      if the config has no accountPackageIdLatest, i.e. the network still runs account v1

    • Parameters

      • params: { amount: bigint; coinType: string; wrapperId: string }

        Wrapper id, raw amount, and coin type

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object and returns the Coin<T>

      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.