Ephemeral Deposits
Using ephemeral 0x-accounts served on the library side
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 direct deposits 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.
Parameters
amountGwei
- token amount to deposit into an account (in pool dimension).
ephemeralIndex
- an index of the ephemeral address.
relayerFee
- a raw relayer fee object 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
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.
Returns
Promise
returns index of the first non-used ephemeral address.
Example
Getting Ephemeral Address at Index
The library generates ephemeral addresses with BIP32 (hierarchical deterministic wallets). So the every address has an index (the last HD path component).
Parameters
index
- an index of requested ephemeral address.
Returns
Promise
returns EphemeralAddress object.
Example
Getting All Used Ephemeral Addresses
Request details of all ephemeral addresses which were already used.
Returns
Promise
returns array of EphemeralAddress objects.
Example
Retrieving Number of Token Transfers To the Address
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
Retrieving Number of Token Transfers From the Address
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
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.
Parameters
index
- an index of the ephemeral address
Returns
A string with the private key in the hex representation
Example
Last updated