Skip to content
This is the code that created the LSF asset in the previous step. It sends one transaction that creates a mint account, switches on five Token-2022 extensions, and writes the asset’s metadata. Press Run to step through its output on a local test network (Surfpool). Nothing is sent from your browser, and there’s nothing to install.
create-asset.ts
Output of createAsset(issuer)Local test network (Surfpool)
await createAsset(issuer)
Mint: HZum3YzcFTMWDGAQWBYMLDUACtLcxc1pF67doKooqYzY
Extensions: MetadataPointer, PausableConfig, PermanentDelegate, DefaultAccountState, TokenMetadata
Signature: 5AJfoLZSwWu7J568eoPPj9NFoGAzYDAS6uBD7zb4bb6E7dNbDRPYdxX6s8hZEo9qqeTpihA9zg6P9sGneEXURiL4
Fee: 10000 lamports
Confirmed

​What the code does

createAsset(issuer) builds one transaction with these instructions, in order:
  1. Create the mint account (getCreateAccountInstruction). It is funded for the final size including metadata, but allocated without the metadata, which is written after the mint is initialized.
  2. Configure the extensions that must be set before the mint is initialized (getPreInitializeInstructionsForMintExtensions).
  3. Initialize the mint (getInitializeMintInstruction) with 6 decimals. The issuer is both the mint authority, who can issue more LSF, and the freeze authority, who approves and freezes holders.
  4. Write the metadata (getPostInitializeInstructionsForMintExtensions).
Each extension sets one rule:
  • MetadataPointer and TokenMetadata: the name (Lisbon Solar Fund), symbol (LSF), a URI for offchain details, and an extra isin field, stored on the mint itself.
  • PausableConfig: the issuer can pause and resume every transfer, mint, and burn.
  • PermanentDelegate: the issuer can move or burn tokens in any account without the holder’s signature.
  • DefaultAccountState set to Frozen: every new token account starts frozen, so nobody can receive LSF until the issuer approves them.
The send helper it imports from ./config builds, signs, sends, and confirms the transaction. You’ll see it in the next step. Same mint in web3.js or Rust: see the cookbook recipe Create a mint with extensions.

​What this code creates

Choose the extensions before you launch. Most extensions can’t be added to a mint after it is created. Decide on pausing, the default account state, and a permanent delegate up front, or plan a migration to a new mint.
To change the code and run it yourself, continue to the next step.