modifyTokenSupply

The modifyTokenSupply() operation allows you to mint (increase) or burn (decrease) the total supply of a token on KeetaNet. This is a low-level supply management tool that modifies the global token supply stored in a given token account.

This operation is part of the transaction builder and must be published to take effect.

When to Use

  • Minting new tokens to increase supply (e.g. when issuing rewards or enabling inflation).

  • Burning tokens to reduce supply (e.g. for deflationary models or manual corrections).

  • Dynamically adjusting circulating supply in response to governance or economic rules.

How It Works

1

Get a Token Account

You need the token account you want to modify. This is usually derived from a known public key.

const tokenAccount = Client.lib.Account.fromPublicKeyString(tokenPublicKey)
2

Initialize a Builder

Start a transaction builder using userClient.initBuilder().

const builder = userClient.initBuilder()
3

Call modifyTokenSupply()

Provide an amount and a token account:

  • Positive values mint tokens.

  • Negative values burn tokens. The amount must be an integer or a BigNumber.

const builder = userClient.initBuilder()
builder.modifyTokenSupply(1000n, { account: tokenAccount }) // Mint 1000 tokens
await userClient.publishBuilder(builder)

const builder = userClient.initBuilder()
builder.modifyTokenSupply(-500n, { account: tokenAccount }) // Burn 500 tokens
await userClient.publishBuilder(builder)
4

Publish the Builder

Send the transaction to the network using userClient.publishBuilder()

await userClient.publishBuilder(builder)

Full Example

// Step 1: Load token account
const tokenAccount = Client.lib.Account.fromPublicKeyString(tokenPublicKey)
if (!tokenAccount.isToken()) {
  throw new Error("Invalid token public key")
}

// Step 2: Start builder
const builder = userClient.initBuilder()

// Step 3a: Burn 100 tokens
builder.modifyTokenSupply(-100n, { account: tokenAccount })
// Step 3b: Or mint 100 tokens
builder.modifyTokenSupply(100n, { account: tokenAccount })

// Step 4: Publish the transaction
await userClient.publishBuilder(builder)

Method

modifyTokenSupply(
  amount: BigNumber | number,
  options: {
    account: Account; // The token account whose supply you're modifying
  }
): void

Last updated