Modificar el suministro de tokens

Si se creó un token con la propiedad �?strong>Supply Mutable�? puede crear más tokens o reducir el suministro total.

requisitos previos

  • Complete creando una guía de token.

  • Haber registrado un token mutable de suministro.

Método #01: Uso de la billetera de escritorio

  1. Haga clic en la pestaña �?strong>Token�?en el menú del lado izquierdo.

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

2. Haga clic en el icono de edición (representado por un bolígrafo) en el lado derecho del token que desea editar. Haga clic en �?strong>modificar oferta�? Nota:

resources/images/screenshots/modify-token-supply-2.gif
  1. Seleccione �?strong>Dirección de cambio de suministro�?para indicar si desea aumentar o disminuir el suministro. Luego ingrese la cantidad por la que desea editar el suministro relativo. Haz clic en �?strong>Enviar�? Verifique la información en la página siguiente e ingrese la contraseña de su billetera. Haga clic en �?strong>Confirmar�?

En nuestro ejemplo, la oferta relativa se incrementa en 1.000.000. Dado que la propiedad de divisibilidad de la ficha es 0, el cambio en la oferta absoluta es idéntico.

Note

If you enter a negative number, it will do the inverse of the indicated �?strong>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. Puede verificar el cambio en el suministro en la página �?strong>Tokens�? Si aún ve el suministro anterior, intente hacer clic en el ícono de actualización en la parte superior derecha.

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

Método #02: Usando el SDK

1. Defina una TokenSupplyChangeTransaction como en el siguiente fragmento de código. Luego, reemplace tokenId y divisibility con las propiedades del token actual. Edite delta con la cantidad relativa de fichas que desea aumentar.

// 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. Firme la transacción con la cuenta del creador del token y anúnciela a la red.

// 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();
        }

De lo contrario, puede disminuir el suministro de un token cambiando TokenSupplyChangeAction.Increase a TokenSupplyChangeAction.Decrease. En este segundo caso, la cuenta del creador del token debe poseer al menos unidades delta para disminuir el suministro de tokens.

Método #03: Uso de la CLI

Abra una ventana de terminal y ejecute el siguiente comando.

Reemplace 7cdf3b117a3c40cc con el identificador del token y 1000000 con las unidades absolutas a aumentar.

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