High Level Flow
Deposit ETH -
- Make depositEtherFor call on RootChainManager and send the required ether.
Withdraw ETH -
- Burn tokens on matic chain.
- Call exit function on RootChainManager to submit proof of burn transaction. This call can be made after checkpoint is submitted for the block containing burn transaction.
Configuring Matic SDK
Install Matic SDK (2.0.2)
While creating MaticPOSClient object network,version,maticProvider, parentProvider and posRootChainManager need to be provided.
ETH can be deposited to matic chain by calling depositEtherFor on RootChainManager contract. Matic POS client exposes depositEtherForUser method to make this call.
ETH is deposited as ERC20 token on Matic chain. For withdrawing it follow the same process as withdrawing ERC20 tokens.
User can call withdraw function of MaticWETH contract. This function should burn the tokens. Since Ether is an ERC20 token on matic chain, use burneth method of Matic POS client exposes to make this call.
Store the transaction hash for this call and use it while generating burn proof.
Once the checkpoint has been submitted for the block containing burn transaction, user should call the exit function of RootChainManager contract and submit the proof of burn. Upon submitting valid proof tokens are transferred to the user. Matic POS client exposes exitERC20 method to make this call.