Modifying the token supply

If a token was created with the “Supply Mutable” property, you can make more tokens or reduce the total supply.

Prerequisites

Method #01: Using the Desktop Wallet

  1. Click on the “Token” tab on the left-side menu.

resources/images/screenshots/modify-token-supply-1.gif

2. Click on the edit icon (represented by a pen) on the right side of the token that you desire to edit. Click “modify supply”. Note:

resources/images/screenshots/modify-token-supply-2.gif
  1. Select the “Supply Change Direction” to indicate whether you desire to increase or decrease the supply. Then enter the amount by you wish to edit the relative supply. Click “Send”. Verify the information on the next page and enter your wallet password. Click “Confirm”.

In our example, the relative supply is increased by 1,000,000. Since the divisibility property of the token is 0, the change in absolute supply is identical.

Note

If you enter a negative number, it will do the inverse of the indicated “Supply Change Direction”. For example, if you choose to increase by -100, the relative supply will decrease by 100. To decrease the supply, the token owner must have at least the number of units to be removed.

resources/images/screenshots/modify-token-supply-3.gif
  1. You can verify the change in supply on the “Tokens” page. If you still see the old supply, try clicking on the update icon on the top right.

resources/images/screenshots/modify-token-supply-4.gif

Method #02: Using the SDK

1. Define a TokenSupplyChangeTransaction as in the next code snippet. Then, replace the tokenId and divisibility with the current token properties. Edit delta with the relative amount of tokens you want to increase.

// replace with network type
const networkType = NetworkType.TEST_NET;
// replace with private key
const privateKey =
  '1111111111111111111111111111111111111111111111111111111111111111';
const account = Account.createFromPrivateKey(privateKey, networkType);
// replace with token id
const tokenIdHex = '7cdf3b117a3c40cc';
const tokenId = new TokenId(tokenIdHex);
// replace with token divisibility
const divisibility = 0;
// replace with token units to increase
const delta = 1000000;

const tokenSupplyChangeTransaction = TokenSupplyChangeTransaction.create(
  Deadline.create(epochAdjustment),
  tokenId,
  TokenSupplyChangeAction.Increase,
  UInt64.fromUint(delta * Math.pow(10, divisibility)),
  networkType,
  UInt64.fromUint(2000000),
);
// replace with network type
const networkType = bitxor_sdk_1.NetworkType.TEST_NET;
// replace with private key
const privateKey =
  '1111111111111111111111111111111111111111111111111111111111111111';
const account = bitxor_sdk_1.Account.createFromPrivateKey(
  privateKey,
  networkType,
);
// replace with token id
const tokenIdHex = '7cdf3b117a3c40cc';
const tokenId = new bitxor_sdk_1.TokenId(tokenIdHex);
// replace with token divisibility
const divisibility = 0;
// replace with token units to increase
const delta = 1000000;
const tokenSupplyChangeTransaction = bitxor_sdk_1.TokenSupplyChangeTransaction.create(
  bitxor_sdk_1.Deadline.create(epochAdjustment),
  tokenId,
  bitxor_sdk_1.TokenSupplyChangeAction.Increase,
  bitxor_sdk_1.UInt64.fromUint(delta * Math.pow(10, divisibility)),
  networkType,
  bitxor_sdk_1.UInt64.fromUint(2000000),
);
        // replace with node endpoint
        try (final RepositoryFactory repositoryFactory = new RepositoryFactoryVertxImpl(
                "NODE_URL")) {
            final NetworkType networkType = repositoryFactory.getNetworkType().toFuture().get();
            // replace with private key
            final String privateKey = "1111111111111111111111111111111111111111111111111111111111111111";
            final Account account = Account
                    .createFromPrivateKey(privateKey, networkType);
            // replace with token id
            final String tokenIdHex = "7cdf3b117a3c40cc";
            final TokenId tokenId = new TokenId(tokenIdHex);
            // replace with token divisibility
            final int divisibility = 0;
            // replace with token units to increase
            final int delta = 1000000;

            final TokenSupplyChangeTransaction tokenSupplyChangeTransaction = TokenSupplyChangeTransactionFactory
                    .create(
                            networkType,
                            tokenId,
                            TokenSupplyChangeActionType.INCREASE,
                            BigDecimal.valueOf(delta * Math.pow(10, divisibility)).toBigInteger())
                    .maxFee(BigInteger.valueOf(2000000)).build();

Note

Bitxor works with absolute amounts. To get an absolute amount, multiply the number of assets you want to increase/decrease by 10divisibility. For example, if the token has divisibility 2, to increase 10 units (relative) you should define 1000 (absolute) instead.

  1. Sign the transaction with the token creator account and announce it to the network.

// replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash =
  '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const signedTransaction = account.sign(
  tokenSupplyChangeTransaction,
  networkGenerationHash,
);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();

transactionHttp.announce(signedTransaction).subscribe(
  (x) => console.log(x),
  (err) => console.error(err),
);
// replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash =
  '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const signedTransaction = account.sign(
  tokenSupplyChangeTransaction,
  networkGenerationHash,
);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new bitxor_sdk_1.RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
transactionHttp.announce(signedTransaction).subscribe(
  (x) => console.log(x),
  (err) => console.error(err),
);
            final String generationHash = repositoryFactory.getGenerationHash().toFuture().get();

            final SignedTransaction signedTransaction = account
                    .sign(tokenSupplyChangeTransaction, generationHash);


            final TransactionRepository transactionRepository = repositoryFactory
                    .createTransactionRepository();
            transactionRepository.announce(signedTransaction).toFuture().get();
        }

Otherwise, you can decrease a token supply by changing TokenSupplyChangeAction.Increase to TokenSupplyChangeAction.Decrease. In this second case, the token creator account must own at least delta units to decrease the token supply.

Method #03: Using the CLI

Open a terminal window and run the following command.

Replace 7cdf3b117a3c40cc with the token identifier and 1000000 with the absolute units to be increased.

bitxor-cli transaction tokensupplychange --action Increase --token-id 7cdf3b117a3c40cc --delta 1000000