The deposit flow
Before your user can trade, they need to deposit funds into StarkEx. To do so, they first deposit funds to the on-chain StarkEx contract. The application should then send a corresponding off-chain deposit transaction, which updates the off-chain state.
Alice makes an on-chain transaction to deposit funds. The deposit operation supports deposits of ETH, ERC-20, ERC-721, and ERC-1155.
deposit function gets the following parameters:
starkKey- The public Stark key that corresponds to the vault id.
assetType- The asset identifier of the token to be deposited.
vaultId- The recipient’s off-chain account.
quantizedAmount- For ERC-20 and ERC-1155, the amount to be deposited. For ERC-721, this value must be
A user can deposit to any vault, even to one that they do not own.
For more information on asset identifiers and quantization, see StarkEx specific concepts.
The off-chain application sends a deposit transaction to the StarkEx gateway, using the
add_transaction API with the
The StarkEx service verifies that there are indeed enough funds in the pending deposits area in the StarkEx smart contract to complete the off-chain deposit.
If the deposit is valid, it is included in a batch to be submitted on-chain along with the validity proof.
Even before the deposit is proven and the proof is accepted on-chain, the funds already exist in Alice’s off-chain vault, and subsequent requests to use these funds can be executed.
As part of the state update, the smart contract deducts the relevant amount of funds from the contract’s pending deposits area.
The application can censor a deposit that is undesirable, such as a deposit to the wrong vault, by not transmitting a corresponding deposit request to the StarkEx gateway.
In such a case that user is then able to reclaim their locked on-chain funds by calling the
Only the owner of the Stark key that is specified in the
On-chain functions including
depositCancelin Deposit and withdrawal for off-chain accounts
StarkEx REST API reference