Links

Withdraw Funds from Escrow

Command

To withdraw funds deposited previously to an escrow account associated to a chainlet, you will need the chain-id associated to the chainlet.
Please note that unlike escrow deposits, that allow you to specify a specific amount, withdrawing of funds from an escrow account withdraws all the funds you deposited. This is an all-or-nothing operation. It will only allow you to withdraw funds that have been deposited from an account that you own or control.
To withdraw funds from an escrow account, use
sagacli account withdraw-escrow <chain-id> \
--from <account address or key name making the withdrawal>

Withdrawal Example

Let us step through the withdrawal with the help of an example.
Let us assume that we have a chainlet with a chain-id of magicwarriors_1679599719-1.
Prior to making the withdrawal, this chainlet had access to funds from two separate accounts i.e. one belonging to the chainlet owner, and the other belonging to a different user with a key named fundkey.
$ sagacli account get-escrow magicwarriors_1679599719-1
ChainId TotalBalance Funder FunderDeposit
------- ------------ ------ -------------
magicwarriors_1679599719-1 30000tsaga saga1rdssl22ysxyendrkh2exw9zm7hvj8d2ju346g3 28000.000000tsaga
magicwarriors_1679599719-1 30000tsaga saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re 2000.000000tsaga
Now, the user with the key fundkey wishes to withdraw his/her contribution of 2000tsaga tokens from the chainlet's escrow.

Checking the Account Balance Pre-Withdrawal

Before we process this withdrawal, let us take a look at the account balance associated with the key fundkey:
$ sagacli account balance --address saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re
Amount Denom
------ -----
8000 tsaga
Account saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re (associated with key fundkey) has a balance of 8000tsaga tokens.

Process Escrow Withdrawal

Now, we will process an escrow withdrawal from chainlet magicwarriors_1679599719-1
To do so, we will execute a withdraw-escrow transaction in the following manner:
$ sagacli account withdraw-escrow magicwarriors_1679599719-1 --from saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re
You are about to sign and broadcast a transaction, with the following configurations:
* Address: saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re
* Network RPC: tcp://spc.sp1.sagarpc.io:26657
* Platform Chain ID: cassiospc-1
* Ledger: false
* Message Type: *types.MsgWithdraw
* Message Detail:
creator:"saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re"
chainId:"magicwarriors_1679599719-1"
Do you want to proceed? (y/N):
y
2023-03-23T15:13:23-05:00 INF tx broadcasted to the remote node code=0 gas_used=69449 gas_wanted=200000 hash=DFA654213E4402D5D6B716847D83CF0F851CBF0E1891F51638D57A8386B9B67B
ChainId TotalBalance Funder FunderDeposit
------- ------------ ------ -------------
magicwarriors_1679599719-1 28000tsaga saga1rdssl22ysxyendrkh2exw9zm7hvj8d2ju346g3 28000.000000tsaga
As can be seen from the output above, the withdrawal returned the funds to the account with the key fundkey whose account address is saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re.

Checking the Account Post-Withdrawal

We can also check whether the account address saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re received the funds back and that its account balance was updated:
$ sagacli account balance --address saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re
Amount Denom
------ -----
10000 tsaga
Yes, the account saga14hyhswxf0shnpzup406yvjejmfsrjnvzq897re received all of the funds (2000tsaga tokens) from the escrow, and its balance was correctly updated.
IMPORTANT: Withdrawing all of the funds in a chainlet escrow account, on behalf of all funders, will change the escrow account balance to zero which will instruct the SAGA Platform to stop running the chainlet and its related RPC and Chainlet Explorer infrastructure and services. In order to keep your chainlet live, make sure the chainlet escrow account has always enough funds to pay for the epoch fees.

Further Details

For further details and options on escrow withdrawal, please see
sagacli account withdraw-escrow --help