Money Partition
In this tutorial, you will learn through practical examples how to use the Money Partition capabilities to make payments from one wallet to another, manage bills in your wallet, and swap smaller bills into one larger bill.
This tutorial addresses the local devnet flow. To sync transactions with the public testnet, add --rpc-url
flag with the following URL to wallet subcommands:
--rpc-url https://money-partition.testnet.alphabill.org
Prerequisites
Before you can begin, make sure you have completed the following steps:
- CLI wallet set up and additional wallet created.
- Local devnet set up and running on your machine.
- Devnet funds deposited into your wallet.
- Funds added to fee credit balance for managing fees on Money Partition.
Transfer Bills
Start by transferring some ALPHA from your default wallet to your second wallet. In this example, the second wallet is located at ~/.alphabill/wallet2
.
-
Got to the
alphabill-wallet/build
directory and run the following command to list the public key of your second wallet:./abwallet wallet get-pubkeys \
--wallet-location ~/.alphabill/wallet2Example response:
#1 0x022b621b40c0b8a404a56a364fad84c74408a9f9880c979ab96c7ae651ec96670a
The output of this command will be referred as
INSERT_YOUR_WALLET_2_PUBKEY
in the commands below. -
Transfer a bill worth of 1 ALPHA to your second wallet:
./abwallet wallet send \
--address INSERT_YOUR_WALLET_2_PUBKEY \
--amount 1infoThe default
--rpc-url
flag value is used here. Each wallet subcommand requires a connection to partition's RPC node, which in case of the Money Partition is started onlocalhost:26866
.You should see output like in the example below:
Example response:
Successfully confirmed transaction(s)
Paid 0.000'000'01 fees for transaction(s). -
Confirm both wallet balances:
-
Default wallet:
./abwallet wallet get-balance
Example response:
#1 9'999'999'997.999'999'97
Total 9'999'999'997.999'999'97 -
Second wallet:
./abwallet wallet get-balance \
--wallet-location ~/.alphabill/wallet2Example response:
#1 1.000'000'00
Total 1.000'000'00
-
-
Prior to the next step, you need to send some additional bills to the second wallet. In fact, you should run the following two commands a total of five more times:
./abwallet wallet send \
--address INSERT_YOUR_WALLET_2_PUBKEY \
--amount 1This will have the effect of sending five additional 1 ALPHA bills from your default wallet to the second wallet, for a total of six bills, each with a denomination of 1 ALPHA.
Check Bills
Before consolidating all these small bills into one larger bill, run the wallet bills list
command to inspect bill IDs and values in both wallets:
-
Default wallet:
./abwallet wallet bills list
Example response:
Account #1
#1 0x5E0823D5F1B1C34B4B1DE355C5B20903CAC86B56DF67E49723A3F2114B6D74E100 9'999'999'997.999'993'96The output shows that the wallet contains one bill worth 9'999'999'997.999'993'96 ALPHA.
-
Second wallet:
./abwallet wallet bills list \
--wallet-location ~/.alphabill/wallet2Example response:
Account #1
#1 0x5E0823D5F1B1C34B4B1DE355C5B20903CAC86B56DF67E49723A3F2114B6D74E100 1.000'000'00
#2 0x66D0DDFE22EBC1962D9C00F006CFB96FDF62533A6EB98F20F1153ECAAACD65AB00 1.000'000'00
#3 0x9FBD4B5E2E81654443F709FA23E2B70B04D420965E30B7C35AAF95C03ED92C3600 1.000'000'00
#4 0xB9CD290DC5C42CB8DD79EAC66138B68621FC1D383883643E5FACE0A9F42AD64F00 1.000'000'00
#5 0xBE138C62FE7A275EFFDB558C134848CE59FDE694F81C9E8BCA2FF18B4F9C859F00 1.000'000'00
#6 0xC40647AD6ADE55FAB671D4B254AA8B5E45CA41DC250DDF6DF2B4602D331C708700 1.000'000'00The output shows that the wallet contains six bills, each worth 1.000'000'00 ALPHA.
Consolidate Bills
You can swap your six 1 ALPHA bills for one larger bill with a denomination of 6 ALPHA. This is called "dust collection", where smaller bills are replaced by a single bill having the same total value. It's like making change in reverse. Alphabill uses an inbuilt swap mechanism to allow users to reduce the number of bills their wallet needs to hold. This reduces the amount of dust in the system, which translates into better performance for the network, and also reduces the amount of space used by user wallets.
-
Before you can consolidate these small bills, add some fee credit to your second wallet:
./abwallet wallet fees add \
--wallet-location ~/.alphabill/wallet2 \
--amount 0.000'000'06Example response:
Successfully created 0.00000006 fee credits on money partition.
Paid 0.000'000'01 fee for transferFC transaction from wallet balance.
Paid 0.000'000'01 fee for addFC transaction from fee credit balance. -
Now you can swap these smaller bills for a larger one:
./abwallet wallet collect-dust \
--wallet-location ~/.alphabill/wallet2The log output should contain some information like in the example below:
Example response:
Dust collection finished successfully.
-
Finally, confirm that your second wallet contains now only a single bill with a denomination of 6 ALPHA:
./abwallet wallet bills list \
--wallet-location ~/.alphabill/wallet2Example response:
Account #1
#1 0x5E0823D5F1B1C34B4B1DE355C5B20903CAC86B56DF67E49723A3F2114B6D74E100 6.000'000'00
Next Steps
For more information about Money Partition, see Alphabill core papers and FAQ.