w3-kitDocs

Create Token

Create a new token on EVM (ERC-20 contract deployment) or Solana (SPL Token mint account).

EVM and Solana

Installs viem, @solana/web3.js, @solana/spl-token

create-token/evm.tsx
"use client";

import { useAccount } from "wagmi";
import { useState } from "react";

// ★ Minimal ERC-20 — for production, use OpenZeppelin's full implementation
const MINIMAL_ERC20_BYTECODE = "0x" as `0x${string}`; // Placeholder — see .learn.md for full contract

// In practice, you'd compile an OpenZeppelin ERC-20 contract and use its bytecode
// This recipe focuses on the deployment pattern, not the contract code

const erc20Abi = [
  {
    type: "constructor",
    inputs: [
      { name: "name", type: "string" },
      { name: "symbol", type: "string" },
      { name: "initialSupply", type: "uint256" },
    ],
  },
] as const;

export function CreateToken() {
  const { address } = useAccount();
  const [name, setName] = useState("My Token");
  const [symbol, setSymbol] = useState("MTK");
  const [supply, setSupply] = useState("1000000");

  // ★ In production: compile your Solidity contract, import the artifact,
  // and use deployContract with the actual bytecode
  return (
    <div>
      <h2>Create ERC-20 Token</h2>
      <p>Connected: {address}</p>
      <input value={name} onChange={(e) => setName(e.target.value)} placeholder="Token name" />
      <input value={symbol} onChange={(e) => setSymbol(e.target.value)} placeholder="Symbol" />
      <input value={supply} onChange={(e) => setSupply(e.target.value)} placeholder="Initial supply" />
      <p><em>EVM token creation requires deploying a Solidity contract.</em></p>
      <p><em>See the .learn.md for the full OpenZeppelin-based contract and deployment flow.</em></p>
    </div>
  );
}

Create Token — Learn

Two very different approaches

Creating a token reveals one of the biggest architectural differences between EVM and Solana.

EVM: Deploy code

On EVM, a token IS a smart contract. To create a token, you write Solidity code that implements the ERC-20 interface:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("My Token", "MTK") {
        _mint(msg.sender, initialSupply * 10 ** decimals());
    }
}

You compile this to bytecode, then deploy it via a transaction. The deployed contract gets its own address and stores all token state (balances, allowances, total supply).

Because you write the code, you can add any logic: transfer taxes, max wallet limits, auto-liquidity, vesting schedules, etc.

Solana: Create an account

On Solana, ALL tokens use the same program (SPL Token). Creating a token means:

  1. Generate a new keypair (this becomes the mint address)
  2. Create an account at that address with enough SOL for rent
  3. Initialize it as a "mint" via the SPL Token program
const mint = await createMint(
  connection,
  payer, // Who pays for the account
  mintAuthority, // Who can mint new tokens
  freezeAuthority, // Who can freeze accounts (or null)
  decimals, // Token precision
);

That's it. No code to write, no compilation, no deployment. The SPL Token program already knows how to handle transfers, approvals, burns, etc.

Authorities (Solana)

Solana tokens have two key authorities:

Mint Authority — can create new tokens via mintTo. If you renounce this (set to null), the supply is permanently fixed.

Freeze Authority — can freeze any token account, preventing transfers. Stablecoins (USDC) use this for compliance. For most tokens, you should set this to null.

Contract verification (EVM)

After deploying an ERC-20 on EVM, users can't see the source code — only the bytecode. "Verifying" the contract on Etherscan means uploading the source code and proving it compiles to the deployed bytecode. This lets anyone audit the token's logic.

Unverified token contracts are a red flag — if you can't read the code, you don't know what it does.

Common patterns

Fixed supply: Mint all tokens in the constructor (EVM) or via mintTo then renounce mint authority (Solana).

Mintable: Keep mint authority to create tokens on demand (rewards, staking yields).

Burnable: Allow holders to destroy their own tokens, reducing total supply. Standard in OpenZeppelin, supported natively in SPL Token.