DEV Community

Cover image for How to Create a Solana Token: With Code (TypeScript CLI) or Without
Sanket
Sanket

Posted on

How to Create a Solana Token: With Code (TypeScript CLI) or Without

I created the same token twice on devnet this week. The classic SPL version cost 0.0163 SOL. The Token-2022 version cost 0.0043 SOL. Most of that gap is one 0.01 SOL fee that most tutorials skip.

I have been building token tooling since late 2020, Solidity first and mostly Solana now. The question I still get most is the simple one: how do I create a Solana token that shows up in a wallet with a name, a symbol and a logo, and not as a bare mint address? My answer depends on whether you want to write code.

If you just want the token, use Tokenry's Solana Token Creator. You set the name, symbol, logo and supply, choose whether to revoke the mint and freeze authorities, and sign from your browser wallet. No code. (I build Tokenry, so that one is my own tool.)

If you would rather write code, the rest of this post is for you. One TypeScript command creates the mint, the metadata, the supply and the optional revokes in a single transaction, on devnet by default. The code is in the create-solana-token repo, and every cost in this post comes from my own devnet runs of it. (If a bare mint is all you need, the official CLI quickstart with spl-token is shorter. It adds metadata as an optional Token-2022 step, but it has no Metaplex path and no cost breakdown.)

What the script does in one transaction

For a classic SPL token, the script builds these instructions, in this order:

  1. Create the mint account (82 bytes).
  2. InitializeMint2, with your wallet as mint and freeze authority.
  3. Metaplex CreateV1, which creates the metadata account with the name, symbol and URI.
  4. Create your associated token account (idempotent).
  5. MintToChecked for the supply.
  6. Optional: SetAuthority to null, once for minting and once for freezing.

All of it goes into one v0 transaction. Before anything is signed, the script simulates the transaction and sets the compute unit limit to what the simulation used. If any program fails in the simulation, the run stops there and nothing gets signed or sent, so you never end up with a mint that exists but has no metadata. Here is the bit of src/create-token.ts that does it:

  // Simulates the transaction (any program error stops here, before sending)
  // and sets the compute unit limit to what it really uses.
  const estimateAndSetLimits = estimateAndSetResourceLimitsFactory(estimateResourceLimitsFactory({ rpc }));
  const message = await estimateAndSetLimits(pricedMessage);
Enter fullscreen mode Exit fullscreen mode

The order matters more than it looks. CreateV1 must run while your wallet is still the mint authority, so the revokes have to come last. I learned this the annoying way. The first time I scripted a Solana token with metadata end to end, in 2025 when I moved most of my work to Solana, I sent the mint, the revoke and the metadata as separate transactions. The metadata call failed because the mint authority was already gone, and I was left with a nameless token on devnet. Since then everything goes into one transaction, with the revoke at the end.

With --program token-2022 the flow changes. There is no separate metadata account: the name, symbol and URI are written into the mint itself through the metadata pointer and token metadata extensions. The order is strict. InitializeMetadataPointer must come before InitializeMint2 (see the metadata pointer guide), and InitializeTokenMetadata comes after it and grows the account. The script creates the mint with space for the pointer only, but funds it with rent for the final size, because growing the account adds no lamports (Token-2022 metadata docs).

Cost is only one input when you pick a program. This comparison of SPL Token and Token-2022 covers the rest.

Setup: Node, a throwaway keypair and devnet SOL

You need Node.js 22 or newer and npm. I ran everything on Node 24.13.1 with npm 11.8.0. Clone the create-solana-token repo linked above, then install and typecheck:

cd create-solana-token
npm install
npm run typecheck
Enter fullscreen mode Exit fullscreen mode

The typecheck runs tsc --noEmit and should finish with no errors. These are the versions the repo pins, and they were also the latest on npm when I checked on 21 November 2026:

Package Version
@solana/kit 8.6.0
@solana/sysvars 8.6.0
@solana-program/system 0.16.0
@solana-program/token 0.18.0
@solana-program/token-2022 0.20.1
typescript / tsx 7.0.2 / 4.23.15

Next, a keypair. The script reads a keypair file that pays and signs: --keypair <path>, then the KEYPAIR_PATH variable, then ~/.config/solana/id.json. Use a throwaway keypair made only for devnet, never your main wallet. The repo's README says to make it with the Solana CLI, solana-keygen new, and to keep keypair files out of git. The script reads the file locally and never uploads it. Do not paste its contents anywhere.

Then devnet SOL. As of 21 November 2026, the public devnet RPC refuses airdrops. My request came back with HTTP 410 and "The RPC faucet is closed on this cluster. Request test SOL at https://faucet.solana.com". So use the devnet faucet in the browser: 2 requests every 8 hours by default, more if you sign in with GitHub. For scale, 0.05 devnet SOL covered both tokens in this post with plenty left.

The default RPC endpoints are public and rate limited, and I got HTTP error (429): Too Many Requests while setting up. If that happens, set RPC_URL to your own endpoint. If RPC_URL points at a different cluster than your flags, the script stops before doing anything, which has saved me from my own typos.

The metadata JSON

On chain, the token carries a name, a symbol and a URI. The URI points to a JSON file with everything else. This is the repo's examples/metadata.json, with the image URL swapped for a placeholder because you will host your own:

{
  "name": "Demo Token",
  "symbol": "DEMO",
  "description": "A test token created on devnet with create-solana-token.",
  "image": "<URL of your token image>"
}
Enter fullscreen mode Exit fullscreen mode

The on-chain name and symbol come from your --name and --symbol flags, and the JSON should repeat them exactly. Host the file, and the image, at a public URL that will still be there in a year.

The repetition matters because Phantom prioritizes on-chain metadata that follows the Token Metadata Standard. When a name and symbol exist both on chain and in the JSON, the on-chain ones win. If your flags say one thing and your JSON says another, people see a mix and get confused.

Mind the limits. Metaplex allows a name of 32 bytes, a symbol of 10 bytes and a URI of 200 bytes. The limits count bytes, so a name with non-ASCII characters hits them sooner than its length suggests. The script checks before it connects to anything:

Error: --symbol is 12 bytes; Metaplex metadata allows at most 10

Run it

The classic SPL token with Metaplex metadata, 1,000,000 supply, default 9 decimals. Replace <URL of your metadata.json> with the URL of your hosted JSON, and drop the angle brackets: bash reads them as redirection. The keypair path is mine; use the path to your own throwaway file.

npm run create -- --keypair ../keys/devnet-throwaway-keypair.json --name "Demo Token" --symbol DEMO --uri <URL of your metadata.json> --supply 1000000
Enter fullscreen mode Exit fullscreen mode

My run, trimmed (npm header, URI line and links cut):

Creating a token on devnet

  Cluster         devnet (api.devnet.solana.com)
  Program         Token (classic SPL) with Metaplex metadata
  Name            Demo Token
  Symbol          DEMO
  ...
  Decimals        9
  Supply          1,000,000 to CuapNURrm3jsqWsrLWzCw8q2EwCfRwKpmYGRH8cLRjBS
  Revoke mint     no
  Revoke freeze   no
  Wallet balance  0.05 SOL
  Estimated cost  0.01629904 SOL

Sending 2Xg3kCgEcVpCwy6AXHjomubrGzE2rPAaQyE3a5t1QQAUpcz4xrvfXc883GgXnom9agPXpbwbXGdL91QP9B1MdSmh ...

Token created on devnet

  Program                    Token (classic SPL) with Metaplex metadata
  Mint                       5wQ7Hk7zBg7bB8ubZALkMiBtBUahFQZw8VGkCLC3cDGs
  Token account              B2z3NodxA5QRNGufitghkYsTZjtnMTY2cNbbRSxToG73
  Metadata account           3aLMZcgaLWPY7ATciYNF1XLHJNtRPrJgiVEm39cEQXfy
  Supply                     1,000,000 DEMO
  Decimals                   9
  Mint authority             CuapNURrm3jsqWsrLWzCw8q2EwCfRwKpmYGRH8cLRjBS
  Freeze authority           CuapNURrm3jsqWsrLWzCw8q2EwCfRwKpmYGRH8cLRjBS
  Metadata update authority  CuapNURrm3jsqWsrLWzCw8q2EwCfRwKpmYGRH8cLRjBS (metadata can still be edited)

Cost
  Mint account rent   0.0010668 SOL
  Token account rent  0.00148844 SOL
  Metadata account    0.0137338 SOL
  Transaction fee     0.00001 SOL
  Total spent         0.01629904 SOL
...
Enter fullscreen mode Exit fullscreen mode

The estimate and the final cost match to the lamport. You can check the transaction on Solana Explorer.

Now the Token-2022 version, this time with both revokes. The output below starts at the result; the plan part looks like the one above:

npm run create -- --keypair ../keys/devnet-throwaway-keypair.json --program token-2022 --name "Demo Token" --symbol DEMO --uri <URL of your metadata.json> --supply 1000000 --revoke-mint --revoke-freeze
Enter fullscreen mode Exit fullscreen mode
...
Token created on devnet

  Program                    Token-2022 with the metadata extension
  Mint                       4bkjvqa52bFWRG8wwtdm5b8YybZM4k2PgWyjtr2TEKzQ
  Token account              CfhNZ4MGYw4bz9wb7wyEzmfTQBuacDKk5EfuazbuVKTs
  Supply                     1,000,000 DEMO
  Decimals                   9
  Mint authority             none (revoked)
  Freeze authority           none (revoked)
  Metadata update authority  CuapNURrm3jsqWsrLWzCw8q2EwCfRwKpmYGRH8cLRjBS (metadata can still be edited)

Cost
  Mint account rent   0.00281432 SOL
  Token account rent  0.00151384 SOL
  Transaction fee     0.00001 SOL
  Total spent         0.00433816 SOL
...
Enter fullscreen mode Exit fullscreen mode

There is no metadata account line this time, because the metadata lives on the mint. Here is the Token-2022 transaction: create, metadata, mint and both revokes in one go.

The flags you will actually use:

  • --decimals: 0 to 19, default 9.
  • --supply: in whole tokens, minted to your wallet.
  • --program: token (default) or token-2022.
  • --revoke-mint and --revoke-freeze: permanent, more on that below.
  • --priority-fee: micro-lamports per compute unit, default 0.
  • --mainnet: use mainnet instead of devnet.

I did not run mainnet for this post. With --mainnet the script prints "This spends real SOL on mainnet. Revoked authorities can never be restored." and waits for you to type yes. It refuses to run at all when its input is not a terminal, so a script or a pipe cannot answer for you.

Where the SOL goes (as of November 2026)

Measured on devnet on 21 November 2026, from the payer's balance before and after each transaction. Devnet and mainnet returned the same rent minimums that day.

Cost of creating a Solana token on devnet: classic SPL with Metaplex 0.01629904 SOL, Token-2022 with metadata 0.00433816 SOL

Rent is (account bytes + 128) x 5,080 lamports. The 82-byte mint: 210 x 5,080 = 1,066,800 lamports, or 0.0010668 SOL. Rent is a deposit that comes back when an account is closed. In this setup the mint account cannot be closed, so its rent stays locked. The token account rent comes back if you empty and close that account.

The biggest line of the classic bill is the Metaplex metadata account: 0.0137338 SOL. Only 0.0037338 SOL of that is rent for 607 bytes. The other 0.01 SOL is the Metaplex protocol fee for a Token Metadata Create, and that one fee is more than 60% of the total. Token-2022 skips both the separate account and the fee. Its mint is bigger (426 bytes in my run) because it carries the metadata, and its rent grows by 0.00000508 SOL for every byte of name, symbol and URI. Even so, the whole Token-2022 token cost a little over a quarter of the classic one.

The network fee is the base fee of 5,000 lamports per signature. This transaction has two signatures (your wallet and the new mint), so 0.00001 SOL. A priority fee is ceil(compute unit price x compute unit limit / 1,000,000) lamports, charged on the requested limit, not on what was used. Since the script sets the limit to the simulated usage, the two match. My runs used 61,028 compute units (classic) and 34,618 (Token-2022), with the default price of 0. The revoke flags added nothing to the bill.

If older guides show higher numbers, they were right for their time. SIMD-0437 cuts the rent rate in steps: 6,960, then 6,333, then 5,080 lamports per byte, with more steps planned down to 696. When I read the rent on mainnet on 21 November 2026, it was already 5,080 lamports per byte (see Solana's reduced rent page). Rent will drop again when the next steps activate, so treat every number here as dated.

Revoking is permanent, and what it does not lock

--revoke-mint and --revoke-freeze set those authorities to null in the same transaction. No instruction brings them back. After --revoke-mint, the supply is fixed forever, and after --revoke-freeze, nobody can freeze a holder's account.

In my experience from the BNB Chain years, buyers checked whether the owner could still mint before they looked at anything else. On Solana that check is the mint authority, so I revoke it on launch tokens. But I still run the exact command on devnet first, because there is no undo.

Neither flag locks the name, symbol or URI. The classic path creates the Metaplex metadata as mutable, with your wallet as update authority. On Token-2022 the metadata update authority is your wallet too. You can see it in the output above: both authorities revoked, and still "metadata can still be edited". If you want the metadata locked as well, that is a separate step, covered in this guide on revoking update authority on Solana.

Errors I would expect you to hit

  • Airdrop refused (410) or 429. See Setup: use the web faucet or your own RPC_URL.
  • Not enough SOL. The script compares your balance with the estimate before it sends anything. On a fresh, empty keypair I got this, with nothing sent:

    Error: Not enough SOL: need about 0.01629904 SOL, wallet has 0 SOL. Get devnet SOL at https://faucet.solana.com.
    
  • No name or logo in the wallet. Check that the JSON URL loads in a browser, that the image URL inside it loads too, and that the name and symbol in the JSON match your flags.

  • A Token-2022 rent error in your own code. If you write the metadata yourself, fund the mint for its final size up front. Growing the account does not add lamports. The repo already does this.

  • Bad flags. These fail before any network call, for example Error: --decimals must be a whole number from 0 to 19.

What I would do next

Run both programs on devnet with your real name, symbol and JSON. Open both mints in the explorer and in your wallet, compare what you see, then decide. Only after that add --mainnet. The code is all in the create-solana-token repo if you want to read it before you trust it. If you go the no-code way instead, this walkthrough of creating a Solana token shows every screen.

For a new token today, would you go with classic SPL plus Metaplex, or Token-2022 with the metadata extension? I am curious what decides it for you.

Top comments (0)