# Create a fixed-supply token

A private token whose whole supply is minted once and can never grow. People hold and send it with the same privacy as PCASH, and no one can see which asset moved. You create an asset whose definition names its metadata and the standard fixed-supply mint rule, with no transfer rule. Its asset ID is the hash of that definition, so neither can ever change.

## How it works

1. Your wallet creates the token in one transaction. It makes a secret, mints the whole supply to itself with that secret, and keeps the secret and the definition. The secret can mint only once, so the supply is fixed for good.
2. You send the token the way you send PCASH.
3. A holder's wallet shows a token by its definition. You share the definition as text or a link, and the holder's wallet checks it against the asset ID before keeping it.

## Create it

The metadata's content digest commits to the token's terms, whatever text you publish with it.

```typescript examples/fixed-supply-token/client.ts
/** Create a token and mint its whole supply to this wallet, once. */
export async function createToken(wallet: Wallet, name: string, symbol: string, supply: bigint): Promise<bigint> {
  const created = await wallet.createAsset({
    metadata: { name, symbol, decimals: 6, contentDigest: createHash("sha256").update(`${symbol} token terms`).digest() },
    supply,
  });
  if (!created.accepted) throw new Error(`${symbol} creation was not accepted`);
  return created.assetId;
}
```

## Send it

```typescript examples/fixed-supply-token/client.ts
/** Send some of it, as a wallet sends PCASH. */
export async function sendToken(wallet: Wallet, assetId: bigint, to: string, amount: bigint) {
  return wallet.sendAsset({ assetId, outputs: [{ to, amount }] });
}
```

## Share its definition

The creator's wallet holds the definition. Its share text works on its own, or in a link's `#d=` fragment, which the website's token page opens.

```typescript examples/fixed-supply-token/client.ts
/** The share text a holder's wallet checks against the asset ID to show the token's name and rules. */
export async function shareText(wallet: Wallet, assetId: bigint): Promise<string> {
  const asset = (await wallet.assets()).find((held) => held.assetId === assetId);
  if (asset?.definition == null) throw new Error("this wallet does not know the token's definition");
  return formatAssetDefinition(asset.definition);
}
```

A holder's wallet refuses a definition that doesn't hash to the asset ID, names the standard rules, and shows any other rule as custom.

```typescript examples/fixed-supply-token/client.ts
/** On the holder's side: check the shared definition against its asset ID and keep it. */
export async function importToken(wallet: Wallet, text: string): Promise<bigint> {
  const { assetId } = await wallet.importAssetDefinition(text);
  return assetId;
}
```

## Limits

* The token has no issuer: no one can mint more, freeze it, or change its name.
* A transaction moves PCASH and at most one other asset.
* While the protocol fee is waived, holders need no PCASH: they can publish their own transactions paying only Ethereum gas, or pay a relayer in the token itself. Once the fee applies, each transaction burns a little PCASH.

## Run it

`just e2e assets` creates, sends, merges, and burns a token against local Ethereum and PCASH nodes with real proofs, and `just e2e token-claims` creates one and hands it out through claim links.
