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
  • Sending Ephemeral Deposits
  • Parameters
  • Returns
  • Example
  • Getting the First Non-Used Ephemeral Address Index
  • Returns
  • Example
  • Getting Ephemeral Address at Index
  • Parameters
  • Returns
  • Example
  • Getting All Used Ephemeral Addresses
  • Returns
  • Example
  • Retrieving Number of Token Transfers To the Address
  • Parameters
  • Returns
  • Example
  • Retrieving Number of Token Transfers From the Address
  • Parameters
  • Returns
  • Example
  • Getting the Ephemeral Address Private Key
  • Parameters
  • Returns
  • Example

Was this helpful?

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

Ephemeral Deposits

Using ephemeral 0x-accounts served on the library side

PreviousGift Cards MaintenanceNextForced Exit

Last updated 1 year ago

Was this helpful?

The ephemeral deposit scheme was designed to give the ability to deposit to a zk-account from the smart contracts (e.g. bridges). The idea is to temporary give control over the deposited funds to some EOA, which can then make a regular permittable deposit.

Such an EOA is an ad-hoc generated account derived from the zk-account spending key. So the library controls ephemeral private keys and has full access over the funds on the ephemeral addresses

Since deposits to a single zkBob account can be made from different smart contract wallets, reusing the same ephemeral EOA address is not a good idea, as it can be used to link together independent deposits. A better option is to use a newly generated EOA address for each new deposit.

Using ephemeral deposit scheme is an early developed feature. At now the are more suitable to process external deposits

Sending Ephemeral Deposits

To use an ephemeral deposit you should send funds to the ephemeral address first. The address must have a sufficient balance to process the deposit and cover the relayer fee.

async depositEphemeral(
    amountGwei: bigint,
    ephemeralIndex: number,
    relayerFee?: RelayerFee,
): Promise<string>

Parameters

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

ephemeralIndex - an index of the ephemeral address.

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

Returns

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

Example

const myAddress = await zkClient.directDeposit(90000000000n, 0);
console.log(`Ephemeral deposit sent to the relayer (job ID = ${jobId})`)
// output: Ephemeral deposit sent to the relayer (job ID = 4736)

Getting the First Non-Used Ephemeral Address Index

Scanning over the ephemeral addresses pool to find the first address which was not in use. The address is considering to be non-used if token balance, native balance, native and permit nonces are zero.

async getNonusedEphemeralIndex(): Promise<number>

Returns

Promise returns index of the first non-used ephemeral address.

Example

const idx = await getNonusedEphemeralIndex();
console.log(`Found nonused ephemeral address at index ${idx}`);
// output: Found nonused ephemeral address at index 3

Getting Ephemeral Address at Index

async getEphemeralAddress(index: number): Promise<EphemeralAddress>

Parameters

index - an index of requested ephemeral address.

Returns

Example

const ephAddr = await getEphemeralAddress(0);
console.log(`First ephemeral address: ${ephAddr.address}`);
// output: First ephemeral address: 0x8ff66a5491a15ac67c596d1e9a6290e56dd4d156

Getting All Used Ephemeral Addresses

Request details of all ephemeral addresses which were already used.

async getUsedEphemeralAddresses(): Promise<EphemeralAddress[]>

Returns

Example

const used = await getUsedEphemeralAddresses();
console.log(`$Used addresses: {used.map((a) => a.address).join(`,\n`)}`);
// output: Used addresses: 0x8ff66a5491a15ac67c596d1e9a6290e56dd4d156,
//         0x8434e839e0fa967fb7b9f624c381d533bcbce05d,
//         0xa78b9d09b307a972cae3be39f9182b7065fb15f4

Retrieving Number of Token Transfers To the Address

async getEphemeralAddressInTxCount(index: number): Promise<number>

Parameters

index - an index of the ephemeral address.

Returns

Promise returns number of incoming token transfers to the ephemeral address with the requested index.

Example

const cnt = await getEphemeralAddressInTxCount(0);
console.log(`Incoming token transfers: ${cnt}`);
// output: Incoming token transfers: 1

Retrieving Number of Token Transfers From the Address

async getEphemeralAddressInTxCount(index: number): Promise<number>

Parameters

index - an index of the ephemeral address

Returns

Promise returns number of outgoing token transfers to the ephemeral address with the requested index.

Example

const cnt = await getEphemeralAddressInTxCount(0);
console.log(`Outgoing token transfers: ${cnt}`);
// output: Outgoing token transfers: 1

Getting the Ephemeral Address Private Key

Use this method only for emergency reasons. Everyone who has the private key has full control over the funds on that ephemeral address.

getEphemeralAddressPrivateKey(index: number): string

Parameters

index - an index of the ephemeral address

Returns

A string with the private key in the hex representation

Example

const privKey = getEphemeralAddressPrivateKey(1);
console.log(`Private key: ${privKey}`);
// output: Private key: 2c7c5924e695bd0aad2145641f92fe3d95faf13d236dba7978c138fb6045ba3c

The library generates ephemeral addresses with (hierarchical deterministic wallets). So the every address has an index (the last HD path component).

Promise returns object.

Promise returns array of objects.

πŸ‘©β€βš•οΈ
BIP32
direct deposits
relayer fee object
EphemeralAddress
EphemeralAddress