For a user to perform a withdrawal in the normal state of affairs, two transactions are required:
An off-chain call to the exchange to initiate a withdrawal.
A call to the on-chain
withdrawfunction to perform the actual withdrawal of funds transferring them to the user account.
The detailed withdrawal flow is described below:
The User makes an off-chain withdrawal request to the exchange.
The Exchange sends the withdrawal transaction to the StarkEx service. Note that withdrawal transactions do not require a user signature.
The StarkEx service generates a proof containing the withdrawal (along with other transaction) and sends it to the blockchain.
The user calls the
withdrawcontract function to withdraw the funds evicted off-chain state.
Part of the public input for the proof containing the withdrawal is the vault content. For applications that want to keep the users balances private, we modify the deposit flow. The user first transfers the funds to a temporary vault and then withdraws them from that vault. The following diagram demonstrates this flow.