Skip to main content

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:

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.

  1. 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/wallet2
    Example response:
    #1 0x022b621b40c0b8a404a56a364fad84c74408a9f9880c979ab96c7ae651ec96670a

    The output of this command will be referred as WALLET2_PUBKEY in the commands below.

  2. Transfer a bill worth of 1 ALPHA to your second wallet:

    ./abwallet wallet send \
    --address WALLET2_PUBKEY \
    --amount 1 \
    --rpc-url https://money-partition.testnet.alphabill.org
    Example response:
    Successfully confirmed transaction(s)
    Paid 0.000'000'01 fees for transaction(s).
  3. Confirm both wallet balances:

    • Default wallet:

      ./abwallet wallet get-balance \
      --rpc-url https://money-partition.testnet.alphabill.org
      Example response:
      #1 98.000'000'00
      Total 98.000'000'00
    • Second wallet:

      ./abwallet wallet get-balance \
      --wallet-location ~/.alphabill/wallet2 \
      --rpc-url https://money-partition.testnet.alphabill.org
      Example response:
      #1 1.000'000'00
      Total 1.000'000'00
  4. 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 1 \
    --rpc-url https://money-partition.testnet.alphabill.org

    This 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 \
    --rpc-url https://money-partition.testnet.alphabill.org
    Example response:
    Account #1
    #1 0x56313D5176F9D2A957C1EECEB37B8C2FFF26CA7819FCA92AA6A230BE84B8861B00 93.000'000'00

    The output shows that the wallet contains one bill worth 97.999'993'96 ALPHA.

  • Second wallet:

    ./abwallet wallet bills list \
    --wallet-location ~/.alphabill/wallet2 \
    --rpc-url https://money-partition.testnet.alphabill.org
    Example response:
    Account #1
    #1 0x80F1C5036BC0FD8F9AF1DC50257D721EED90FAA5F9F0F43F1FA37315E79F28F600 1.000'000'00
    #2 0x802E25B1FBFEB1E4532B95178847C4ADA4F34BE104C636C0D9B51E2765FAF56500 1.000'000'00
    #3 0xDD0658065DC4F3EB202B4DDA2949452CC7B4285C851068796517B0813DD4DECC00 1.000'000'00
    #4 0xBD2DA0A91032811684BE09DAF3D64DBD4F751554025A55A9F9837401C0AB7C6500 1.000'000'00
    #5 0x195AFBF3A771873E608119ED0C354D773A6CE12A02A675F8DA39B2EC44D79B1000 1.000'000'00
    #6 0x6A104FA1F68EF780781FD0F1CE655882E9369910298EB60470B93269EC0BB26A00 1.000'000'00

    The 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.

  1. 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'00 \
    --rpc-url https://money-partition.testnet.alphabill.org
    Example response:
    Successfully created 0.00000100 fee credits on money partition.
    Paid 0.000'000'02 ALPHA fee for transactions.
  2. List bills in your second wallet:

    ./abwallet wallet bills list \
    --wallet-location ~/.alphabill/wallet2 \
    --rpc-url https://money-partition.testnet.alphabill.org
    Example 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'00

    The output shows that the value of one of the 1 ALPHA bills is now decreased by the amount transferred to the fee credit balance.

  3. Now you can swap these small bills for a larger one:

    ./abwallet wallet collect-dust \
    --wallet-location ~/.alphabill/wallet2 \
    --rpc-url https://money-partition.testnet.alphabill.org
    Example 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).
  4. Finally, confirm that your second wallet contains now only a single bill:

    ./abwallet wallet bills list \
    --wallet-location ~/.alphabill/wallet2 \
    --rpc-url https://money-partition.testnet.alphabill.org
    Example response:
    Account #1
    #1 0xBE138C62FE7A275EFFDB558C134848CE59FDE694F81C9E8BCA2FF18B4F9C859F00 5.999'999'00