Skip to content

Latest commit

 

History

History

README.md

Token Minter (Anchor)

Note

This is the Anchor v2 copy of this example. Every anchor command on this page needs the v2 CLI: cargo install anchor-cli --version 2.0.0-rc.1 --locked (avm has no prebuilt binary for this pre-release). The Anchor v1 version of this example is in ../anchor-v1.

Mint tokens from inside your program using the Classic Token Program.

See also: Token Minter overview and the repository catalog.

Major concepts

  • Mint authority on a PDA or signer
  • Token account initialization
  • Amounts: mint_token takes amount in minor units, the raw integer the token program operates on. Clients convert from major units offchain: 1 token with 9 decimals is 1 * 10^9 minor units. The program never scales amounts onchain.

Setup

From this directory (tokens/token-minter/anchor/):

anchor build

Prerequisites: Agave CLI (version in Anchor.toml [toolchain]), Anchor.

Testing

Tests run in-process with LiteSVM. No local validator.

anchor test

This runs cargo test as configured in Anchor.toml. Tests call instruction handlers and check onchain state.

Usage

Read the program programs/ source and Anchor.toml for deployed program IDs. For deployment, use anchor build && anchor deploy against your target cluster.