LogoLogo
zkBob AppLinks & Resources
  • 🦹zkBob Overview
    • zkBob
    • Basic Concepts
      • Getting Started
      • Open-Source and Decentralized
      • Multichain Deployment
      • Usage Statistics
      • Use Cases
        • Employee Salary
        • Vendor Purchasing
      • Development Timeline
      • zk Privacy Solution Comparison
    • zkBob Pools
      • USDC Pool on Polygon (sunsets January 31, 2025)
      • USDC Pool on Optimism
      • ETH Pool on Optimism
      • USDT Pool on Tron (sunsets Oct 29, 2024)
    • Fees
      • Unspent note handling
    • Deposit & Withdrawal Limits
    • Compliance & Security
      • TRM Labs Integration
    • Conferences, Workshops, Videos
      • International Videos
    • Governance
    • BOB Stablecoin
    • zkBob FAQ
  • πŸ¦Έβ€β™‚οΈzkBob Application
    • UI Overview
    • Account Creation
      • Login to an existing account
      • Lost Password
      • Metamask / Web3 Wallet Warning
    • Deposits
    • Transfers
      • Multitransfers
    • Withdrawals
      • Native Token Conversion
    • Generate a Receiving Address
    • Optional KYC
    • zkBob Direct Deposits
    • Support ID
    • Payment Links
    • Integrated Services
    • Multilingual support
      • PortuguΓͺs
      • Русский
      • δΈ­ζ–‡
  • πŸ‘©β€βš•οΈTechnical Implementation
    • zkBob Application Overview
    • Deployed Contracts
    • Smart Contracts
      • zkBob Pool Contract
        • Transaction Calldata
      • Bob Token Contract
      • Verifier contracts
      • Operator Manager Contract
        • Mutable Operator Manager
      • Voucher (XP) Token Contract
    • Accounts and Notes
      • Accounts
      • Notes
    • Relayer Node
      • Relayer Operations
      • Optimistic State
      • REST API
    • zkBob Keys
      • Address derivation
      • Ephemeral keys
    • zkSNARKs & Circuits
      • Transfer verifier circuit overview
    • zkBob Merkle Tree
      • The Poseidon Hash
    • Elliptic Curve Cryptography
    • Transaction Overview
      • Common Structure
      • Memo Block
        • Memo Block Encryption
      • Transaction Types
      • Nullifiers
      • Signing a Transaction
      • The Transaction Lifecycle
    • Client Library SDK
      • Configuration
        • Initializing the client
          • Client Configuration
        • Attaching a User Account
          • Account Configuration
        • Switching Between Pools
      • Account-less Mode Operations
        • Converting Token Amounts
        • Transaction Fees
        • Transaction Constraints
        • Using the Delegated Prover
        • Getting the State
        • Gift Cards
        • Client Library Status
        • Helpers
        • Versioning
      • Full Mode Operations
        • Balances and History
        • Shielded Addresses
        • Account State
        • Fee Estimations
        • Transaction Configuration
        • Sending Transactions
        • Transaction Maintenance
        • Direct Deposits
        • Gift Cards Maintenance
        • Ephemeral Deposits
        • Forced Exit
        • Other Routines
      • Common Types
      • Full Functions List
      • Utilities
  • πŸ‘©β€πŸ«Deployment
    • Trusted Setup Ceremony
    • Contract Deployment
    • Relayer Subsystem
  • πŸ‘·β€β™‚οΈRoadmap
    • On the Roadmap
    • Exploratory Features
      • XP (Experience Points)
        • XP-based Auctions
      • Multi-chain Custom Rollup Deployment
      • Round-robin Operator Manager
      • Compounding
  • πŸ§‘β€πŸ’»Jobs
    • Zero-Knowledge Researcher & Protocol Developer
  • 🧩Resources
    • Visual Assets
    • Hackathons
      • zkBob Cloud
    • Release Notes
      • October 11, 2023
      • July 13, 2023
      • June 13, 2023
      • March 28, 2023
      • January 30, 2023
      • January 16, 2023
      • January 2, 2023
      • Releases 2022
    • Security Audit
    • Github
    • Link tree
Powered by GitBook
On this page
  • Getting Transaction Parts
  • Parameters
  • Returns
  • Example
  • Getting Maximum Available Outgoing Transaction
  • Parameters
  • Returns
  • Example

Was this helpful?

  1. Technical Implementation
  2. Client Library SDK
  3. Full Mode Operations

Transaction Configuration

Getting transaction parts and maximum amount to transfer/withdraw

PreviousFee EstimationsNextSending Transactions

Last updated 1 year ago

Was this helpful?

Getting Transaction Parts

The user's request to send or withdraw money may produce several transactions to the privacy pool in the common case. It depends on both a local account/notes configuration and transfer destinations amount as well. The following method is used to evaluate transactions needed to process request

async getTransactionParts(
    txType: TxType,
    transfers: TransferRequest[],
    relayerFee?: RelayerFee,
    withdrawSwap: bigint = 0n,
    updateState: boolean = true,
    allowPartial: boolean = false,
): Promise<Array<TransferConfig>>

Parameters

txType is transaction type (a member of enum)

This method supports just a TxType.Transfer and TxType.Withdraw transaction types only (deposits are always performed within single transaction). The internal error will thrown for other tx types

transfers - a set of transfer requests (use single request with requested amount for withdrawal as well)

The request's destination field is ignored in this method

relayerFee - a raw which will be used to estimate total transaction fee (will requested under the hood when undefined)

withdrawSwap is an optional amount of tokens which should swap in withdraw transaction. It may influence the typical withdraw transaction cost due to extra fee component (ignored for other transaction types)

updateState - update the state before parts evaluating

allowPartial - try to build result even in case of insufficient balance

Returns

Example

const parts = await zkClient.getTransactionParts(
    TxType.Withdraw,
    [{
        destination: '0x49C92c016d2c7A245aAF5351BD932D9D61536eC0',
        amountGwei: 5000000000n // withdraw 5 BOB
    }],
    undefined,    // fetch relayer fee under the hood
    1000000000,    // swap 1 BOB
);
console.log(`This operation requires ${parts.length} transaction(s)`);
// output: This operation requires 4 transaction(s)

Getting Maximum Available Outgoing Transaction

Calculating maximum available amount for transfers and withdrawals. This estimation doesn't take into account pool contract limits

async calcMaxAvailableTransfer(
    txType: TxType,
    relayerFee?: RelayerFee,
    withdrawSwap: bigint = 0n,
    updateState: boolean = true
): Promise<bigint>
See Also

Parameters

This method supports just a TxType.Transfer and TxType.Withdraw transaction types only (you can deposit any amount in the limit boundaries). The internal error will thrown for other tx types

withdrawSwap is an optional amount of tokens which should swap in withdraw transaction. It may influence the typical withdraw transaction cost due to extra fee component (ignored for other transaction types)

updateState - update the state before parts evaluating

Returns

Promise returns token amount in the pool dimension

Example

const maxAmount = await zkClient.calcMaxAvailableTransfer(TxType.Transfer);
console.log(`You can transfer up to ${maxAmount} BOB`);
// output: You can transfer up to 234.56 BOB

Promise returns array of s which describe all transactions needed to process input request, or a void array if request cannot be processed (e.g. in case of insufficient funds)

txType is transaction type (a member of enum)

relayerFee - a raw which will be used to estimate total transaction fee (will requested under the hood when undefined)

πŸ‘©β€βš•οΈ
minTxAmount()
TxType
relayer fee object
TransferConfig
TxType
relayer fee object