Minka Ledger Docs

Withdraw funds

Describing the process of removing balances from the Ledger system


Use case

In this tutorial we will focus on banks removing/withdrawing the funds from the Minka Ledger system.

Here is a more detailed overview of the steps when it comes to withdrawal process.

Creating a settlement wallet

When a bank chooses to make a withdrawal, it will make a transaction to a settlement wallet that belongs to a clearinghouse.

This means a clearinghouse needs to have such a wallet.

And here we will create one.

$ minka wallet create
? Handle: settlement-wallet
? Bridge: [none]
? Add custom data? No
? Add routes? No
? Signer: clearinghouse
? Signer password for clearinghouse [hidden]
 
✅ Wallet created successfully:
 
Wallet summary:
---------------------------------------------------------------------------
Handle: settlement-wallet
 
Access rules:
#0
  - Action: any
  - Signer:
    - public: eIHlrG0Wr5vl3pDi5Vgqzu5WGE7q/60jsysBmehYKtg=
 
Status: created
 
Luid: $wlt.-00cL3j-UW8I7cV4l
Handle: clearinghouse
Public: eIHlrG0Wr5vl3pDi5Vgqzu5WGE7q/60jsysBmehYKtg=

Bank decides to withdraw funds

The first step in this process is for the bank to send the amount they wish to withdraw to the settlement-wallet.

Just as a reminder, currently we have 2 wallets in our ledger (demo-bank-wallet and settlement-wallet) which you can check using this CLI command in your terminal:

$ minka wallet list
 
╔═════════════════════╤══════════╤══════════╤══════════╗
║  Handle             │  Bridge  │  Custom  │  Routes  ║
╟─────────────────────┼──────────┼──────────┼──────────╢
║  demo-bank-wallet   │  None    │          │  None    ║
╟─────────────────────┼──────────┼──────────┼──────────╢
║  settlement-wallet  │  None    │          │  None    ║
╚═════════════════════╧══════════╧══════════╧══════════╝

To initiate payout, demo-bank signer/user, will create an intent to make a transfer from demo-bank-wallet to settlement-wallet.

This is also how regular balance transfers are made between any other two wallets in the system (and not just settlement-wallet).

$ minka intent create
? Handle: eHFmr4O2iSrrxYGAmuRnt
? Action: transfer
? Source: demo-bank-wallet
? Target: settlement-wallet
? Symbol: usd
? Amount: 300
? Add another action? No
? Add custom data for this intent? No
? Signers: demo-bank
? Signer password for demo-bank [hidden]
 
Intent summary:
---------------------------------------------------------------------------
Handle: eHFmr4O2iSrrxYGAmuRnt
 
Action: transfer
 - Source: demo-bank-wallet
 - Target: settlement-wallet
 - Symbol: usd
 - Amount: $300.00
 
 
? Sign this intent using signer demo-bank? Yes
 
✅ Intent signed and sent to ledger tutorial-ledger
 
Intent summary:
---------------------------------------------------------------------------
Handle: eHFmr4O2iSrrxYGAmuRnt
 
Action: transfer
 - Source: demo-bank-wallet
 - Target: settlement-wallet
 - Symbol: usd
 - Amount: $300.00
 
 
Access rules:
#0
  - Action: any
  - Signer:
    - public: RiQu4adTcR1elbgSSSOW84rviHLofGhXJQpOYdvHcQc=
Luid: $int.-03C0rlvfdcD2ywor

We can also see this new intent in the list of intents:

$ minka intent list
 
╔═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║  Handle                     Action              Source               Target         Amount          Status    ║
╟───────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║  eHFmr4O2iSrrxYGAmuRnt    Transfer    demo-bank-wallet    settlement-wallet      $300.00    usd    completed  ║
╟───────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║  1tBaX8vZcH1V0bFmU7XKP       Issue                   -     demo-bank-wallet    $1,000.00    usd    completed  ║
╚═══════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

The resulting balance of demo-bank-wallet is now $700:

$ minka wallet balances demo-bank-wallet
Balances:
$700.00 (usd)

And the balance of the settlement-wallet is $300:

$ minka wallet balances settlement-wallet
Balances:
$300.00 (usd)

Payout and removing the funds

After the previous steps are done, clearinghouse will:

  • make a payout to the bank
  • remove balance from the Ledger system

To achieve this, a clearinghouse signer will make a new (destroy) intent that removes the balance from the settlement-wallet:

$ minka intent create
? Handle: iBCFhzFpuCxuDI4hoErCp
? Action: destroy
? Source: settlement-wallet
? Symbol: usd
? Amount: 300
? Add another action? No
? Add custom data for this intent? No
? Signers: clearinghouse
? Signer password for clearinghouse [hidden]
 
Intent summary:
---------------------------------------------------------------------------
Handle: iBCFhzFpuCxuDI4hoErCp
 
Action: destroy
 - Source: settlement-wallet
 - Symbol: usd
 - Amount: $300.00
 
 
? Sign this intent using signer clearinghouse? Yes
 
✅ Intent signed and sent to ledger tutorial-ledger
 
Intent summary:
---------------------------------------------------------------------------
Handle: iBCFhzFpuCxuDI4hoErCp
 
Action: destroy
 - Source: settlement-wallet
 - Symbol: usd
 - Amount: $300.00
 
 
Access rules:
#0
  - Action: any
  - Signer:
    - public: eIHlrG0Wr5vl3pDi5Vgqzu5WGE7q/60jsysBmehYKtg=
Luid: $int.-04-tX6uUuLUzCMPk

We can check that new intent was created:

$ minka intent list
 
╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
║  Handle                     Action               Source               Target         Amount          Status    ║
╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║  iBCFhzFpuCxuDI4hoErCp     Destroy    settlement-wallet                    -      $300.00    usd    completed  ║
╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║  eHFmr4O2iSrrxYGAmuRnt    Transfer     demo-bank-wallet    settlement-wallet      $300.00    usd    completed  ║
╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
║  1tBaX8vZcH1V0bFmU7XKP       Issue                    -     demo-bank-wallet    $1,000.00    usd    completed  ║
╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

And we can also check the new settlement-wallet balance:

$ minka wallet balances settlement-wallet
Balances:
$0.00 (usd)

This shows the balance is truly removed from the Ledger system and currency withdrawal is completed.

On this page