Withdraw
There are 4 types of withdraw functions: withdraw, forced withdraw (permissionless), proxy withdraw, and Dunkirk exit.
Calls | EVM Signature | NonEvm Signature | Comment |
---|---|---|---|
Forced Withdraw | On-chain transaction that needs to be initiated towards the according networks | ||
Dunkirk Exit | On-chain transaction that needs to be initiated towards the according networks | ||
Withdraw | zkLink L2 operation that requires two signatures: ECDSA for verification from dApp-end, and EDDSA for circuit verification | ||
Proxy Withdraw | zkLink L2 operation that requires two signatures: ECDSA for verification from dApp-end, and EDDSA for circuit verification | ||
Comment | Ethereum, zkSync, Scroll, Linea, BSC, Polygon, Avalanche, etc. | In the current version, the only non-EVM network that zkLink supports is Starknet | |
proxy withdraw
applies to accounts that can not generate pubkeyhash. For example, a user mistakenly transfers tokens to a smart contract address that does not support pubkeyhash generation. To withdraw the token from Layer2 to Layer1 in such a case, a third-party proxy is required to send the withdrawal request. Noted that the to_address must be THE smart contract address.💡 Fast Withdraw is not a Layer2 function, but a supplementary feature to Layer2 withdraw function.
zkLink verify contract supports Brokers to prepay the withdrawal to users as a substitute to regular withdraws, only if the user agrees to pay the broker fee.
The record of prepayment information is stored in Layer1 smart contracts. When a withdrawal is zk_verified on-chain, the according prepayment record will be checked in
accepts
; if it is included, the to_address will be replaced with the broker address.- The serial execution of the broker logic defined in the smart contract makes sure that: 1. multiple brokers cannot take the same fast withdraw request simultaneously; 2. a single request cannot be approved multiple times.
- The broker records are stored in the contract. Once the prepayment is successfully executed, the broker will definitely receive the prepaid principal.
/// @dev Accept infos of fast withdraw of account
/// uint32 is the account id
/// byte32 is keccak256(abi.encodePacked(receiver, tokenId, amount, withdrawFeeRate, nonce))
/// address is the accepter
mapping(uint32 => mapping(bytes32 => address)) public accepts;
/// @dev Broker allowance used in accept, accepter can authorize broker to do accept
/// @dev Similar to the allowance of transfer in ERC20
/// @dev The struct of this map is (tokenId => accepter => broker => allowance)
mapping(uint16 => mapping(address => mapping(address => uint128))) internal brokerAllowances;

Withdraw & Fast Withdraw Flow
Last modified 2mo ago