1

I know I can make a Token mint with token extensions on the command line with something like:

spl-token initialize-metadata mntTymSqMU4e1NEDdxJ9XoPN4MitCgQ7xxGW6AuRAWQ 'Example token' 'EXMPL' https://raw.githubusercontent.com/solana-developers/opos-asset/main/assets/CompressedCoil/metadata.json

But how do I do this in JS/TS?

1 Answer 1

2

I am answering my own question to help others.

There's a example of creating a token using token extensions metadata in the Solana Labs repo. This has been turned into a helper in the @solana-developers/helpers package.

npm i @solana-developers/helpers

Then:

import { makeTokenMint } from  @solana-developers/helpers

Parameters

  • connection: Connection.
  • mintAuthority: Keypair of the account that will be given permission to make new tokens.
  • name: string, name of the token.
  • symbol: string, like a ticker symbol. Usually in all-caps.
  • decimals: number, how many decimal places the new token will have.
  • uri: string, URI to a JSON file containing at minimum a value for image.
  • additionalMetadata: additional metadata as either Record<string, string> or Array<[string, string]>(optional).
  • updateAuthority: PublicKey (optional) - public key of the account that can update the token.
  • freezeAuthority: PublicKey (optional) - public key of the freeze account, default to null
const mintAddress = await makeTokenMint(
  connection,
  mintAuthority,
  "Unit test token",
  "TEST",
  9,
  "https://raw.githubusercontent.com/solana-developers/professional-education/main/labs/sample-token-metadata.json",
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.