How to Withdraw From a Chain
The withdraw
endpoint sends L2 funds owned by the caller to their L1 address.
- Solo
- Solo (Schema)
- Rust (Schema)
- Go (Schema)
// withdraw from chain to wallet
req := solo.NewCallParams(accounts.Contract.Name, accounts.FuncWithdraw.Name)
_, err := chain.PostRequestSync(req.WithMaxAffordableGasBudget(), wallet)
require.NoError(t, err)
// withdraw from chain *chainID* to wallet
w := coreaccounts.ScFuncs.Withdraw(ctx.Sign(wallet))
w.Func.TransferBaseTokens(1).PostToChain(chainID)
require.NoError(t, ctx.Err)
// withdraw from chain *chainID* to current common account
// (there is no way to specify hname for withdrawals)
let w = coreaccounts::ScFuncs::withdraw(ctx);
w.func.transfer_base_tokens(1).post_to_chain(chainID);
// withdraw from chain *chainID* to current common account
// (there is no way to specify hname for withdrawals)
w := coreaccounts.ScFuncs.Withdraw(ctx)
w.Func.TransferBaseTokens(1).PostToChain(chainID)