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
  • Depositing Funds
  • Parameters
  • Returns
  • Example
  • Transfer Funds Inside a Pool
  • Parameters
  • Returns
  • Example
  • Withdraw Funds From the Pool
  • Parameters
  • Returns
  • Example

Was this helpful?

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

Sending Transactions

Deposit, transfers and withdrawals

PreviousTransaction ConfigurationNextTransaction Maintenance

Last updated 1 year ago

Was this helpful?

Depositing Funds

Send tokens to the privacy pool

async deposit(
    amountGwei: bigint,
    signatureCallback: (request: SignatureRequest) => Promise<string>,
    fromAddress: string,
    relayerFee?: RelayerFee,
    blockNumber?: number,
): Promise<string>
See Also

Parameters

amountGwei - token amount to deposit into an account (in pool dimension)

signatureCallback - a callback with which invoked when needed to ask user to sign data

The signature request type depends on deposit scheme which set in the pool configuration during library init. Currently all deployments use SignatureType.TypedDataV4 signature

fromAddress - the 0x-address which will be used to depositing funds

blockNumber - the client waits until the internal provider becomes synced with the specified block before the input account balance (and allowance if applicable) validation. The waiting interval is hardcoded to 60 seconds. If the provider does not become synced within that interval the transaction is sent.

Returns

Promise returns jobId returned by relayer which can be use to monitor transaction

Example

const jobId = await zkClient.depositPermittable(
      100000000000n, // 100 BOB in pool dimension
      async (signingRequest) => {
          switch (signingRequest.type) {
          case SignatureType.TypedDataV4:
              // signingRequest.data is an object for typed signature
              // which contains domain, types, primaryType and message fields
              return signTypedData(signingRequest.data); // use a 3rd-party lib to sign
          case SignatureType.PersonalSign:
              // signingRequest.data is hex-string representation of signing data
              return sign(signingRequest.data); // use a 3rd-party lib to sign
          default:
              throw new Error(`Signing request with unknown type`);
          }
      },
      '0x49C92c016d2c7A245aAF5351BD932D9D61536eC0',    // depositor address
      undefined    // the actual relayer fee will be requested under the hood
   );
console.log(`Deposit sent to the relayer. A job with ID ${jobId} has been assigned`)
// output: Deposit sent to the relayer. A job with ID 42 has been assigned

Transfer Funds Inside a Pool

Transfer tokens inside a pool to the requested addresses. The function creates a set of transactions (needed to process requests), sends it to the relayer in sequence order and returns a set of job IDs assigned by relayer

async transferMulti(
    transfers: TransferRequest[],
    relayerFee?: RelayerFee
): Promise<string[]>

Parameters

transfers - a set of transfer destinations. A single destination should contain the receiver shielded address and associated funds amount to transfer

Please keep in mind the single transaction can include up to 127 output notes, i.e. if your request contains more than 127 destination addresses additional transactions can be created

Returns

Promise returns array of job IDs (each sent transaction associated with the unique job ID assigned by relayer)

Example

transfers = [{
   // Alice will receives 15 BOB
   destination: zkbob_sepolia:CFSGGVWQpmwxmHEiZ123PXKVxbpv3LthegaSiwS1RKW1o5ExL3zRSRTg3TR9sHF,
   amountGwei: 15000000000n
}, {
   // Bob will receive 42 BOB
   destination: zkbob_sepolia:ELg4LcwsynhEaZWh9SNgWBbK7Xg2tjVyTNCgaxvoy4c7jLNudcJqAdL459RHBdg
   amountGwei: 42000000000n
}];
const jobIds = await zkClient.transferMulti(transfers);
console.log(`Accepted by relayer. Job(s) ${jobIds.join(', ')} created`)
// output: Accepted by relayer. Job(s) 43 created

Withdraw Funds From the Pool

Withdraw tokens to the 0x-address. The function creates a set of transactions (needed to process withdraw), sends it to the relayer and returns a set of job IDs assigned by relayer

async withdrawMulti(
    address: string,
    amountGwei: bigint,
    swapAmount: bigint,
    relayerFee?: RelayerFee
): Promise<string[]>
See Also

Parameters

address - a 0x destination address to the sending withdrawn tokens

amountGwei - tokens amount to be withdrawn (in pool dimension)

swapAmount - part of amountGwei which requested to swap to the native coins on withdrawal (in pool dimension)

Returns

Promise returns array of job IDs (each sent transaction associated with the unique job ID assigned by relayer)

Example

const jobIds = await zkClient.withdrawMulti(
    '0x09d967A5268b64E8334f3a65336C33B7538BFe69',
    25000000000n, // withdraw 25 BOB
    5000000000n,  // swap 5 (of 25 BOB) to MATIC
);
console.log(`Accepted by relayer. Job(s) ${jobIds.join(', ')} created`)
// output: Accepted by relayer. Job(s) 44 created

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

This routine may produce several transactions in rare cases when you have a lot of unspent notes. It can increase overall fee needed for transferring requested funds amount. Please refer to the examples described to better understanding notes aggregation flow

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

This routine may produce several transactions in rare cases when you have a lot of unspent notes. It can increase overall fee needed for the funds withdrawal. Please refer to the examples described to better understanding notes aggregation flow

Swap ability doesn't supported on the each pool. Use method to request how many tokens you can swap on the waithdrawal transaction

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

πŸ‘©β€βš•οΈ
here
here
directDeposit(type, fromAddress, amount, sendTxCallback)
relayer fee object
relayer fee object
relayer fee object
SignatureRequest
getLimits(address, directRequest)
maxSupportedTokenSwap()
maxSupportedTokenSwap
getLimits(address, directRequest)
depositEphemeral(amount, ephemeralIndex, relayerFee)