Money Partition
In this tutorial, you will learn through practical examples how to use the Money Partition capabilities to transfer funds from one wallet to another, manage bills in your wallet, and swap smaller bills into one larger bill.
Prerequisites
Before you begin, make sure you have completed the following steps:
- You have set up two Alphabill CLI wallets.
- You have set up a local Alphabill devnet and it is running on your machine.
- Your default wallet is funded with local devnet ALPHA, and it has enough fee credit to cover transaction fees when interacting with the 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
.
-
Go 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
WALLET2_PUBKEY
in the commands below. -
Transfer a bill worth of 1 ALPHA to your second wallet:
./abwallet wallet send \
--address WALLET2_PUBKEY \
--amount 1infoThe default value for the
--rpc-url
flag is used here. Each wallet subcommand requires a connection to the partition's RPC node. For the Money Partition, this node runs onlocalhost:26866
.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'975.999'999'97
#2 10.000'000'00
Total 9'999'999'985.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. Run the following command a total of five more times:
./abwallet wallet send \
--address WALLET2_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.
List 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 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 credits to your second wallet:
./abwallet wallet fees add \
--wallet-location ~/.alphabill/wallet2 \
--amount 0.000'001'00Example response:
Successfully created 0.00000100 fee credits on money partition.
Paid 0.000'000'02 ALPHA fee for transactions. -
List bills in your 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 0.999'999'00The output shows that the value of one of the 1 ALPHA bills is now decreased by the amount transferred to the fee credit balance.
-
Now you can swap these small bills for a larger bill:
./abwallet wallet collect-dust \
--wallet-location ~/.alphabill/wallet2Example response:
Starting dust collection, this may take a while...
Dust collection finished successfully on account #1. Joined 5 bills with total value of 4.999'999'00 ALPHA into an existing target bill with unit identifier 0xBE138C62FE7A275EFFDB558C134848CE59FDE694F81C9E8BCA2FF18B4F9C859F00. Paid 0.000'000'07 fees for transaction(s). -
Finally, confirm that your second wallet contains now only a single bill:
./abwallet wallet bills list \
--wallet-location ~/.alphabill/wallet2Example response:
Account #1
#1 0xBE138C62FE7A275EFFDB558C134848CE59FDE694F81C9E8BCA2FF18B4F9C859F00 5.999'999'00