Create Token
token.create
Creates a new TIP-20 token, and assigns the admin role to admin (defaults to the Client's account). Learn more
Usage
import { } from './viem.config'
const { , , } = await ..({
: 'USD',
: 'https://example.com/cusd.svg',
: 'My Company USD',
: 'CUSD',
})
.('Address:', )
Address: 0x20c0000000000000000000000000000000000004.('Admin:', )Admin: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbbimport { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Asynchronous Usage
The example above uses a *Sync variant of the action, that will wait for the transaction to be included before returning.
If you are optimizing for performance, you should use the non-sync token.create action and wait for inclusion manually:
import { } from 'viem/tempo'
import { } from './viem.config'
const = await ..({
: 'USD',
: 'https://example.com/cusd.svg',
: 'My Company USD',
: 'CUSD',
})
const = await ..({ }).
const { : { } } = ...(.)Recipes
Assign the Admin Role to a Treasury Multisig
Pass admin to hand role administration to a treasury multisig at deployment, keeping the deployer key out of day-to-day control of the token.
import { } from './viem.config'
const { , } = await ..({
: '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
: 'USD',
: 'My Company USD',
: 'CUSD',
})
.('Admin:', )
Admin: 0x8ba1f109551bD432803012645Ac136ddd64DBA72import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Set Up Issuance for a Payments Backend
Combine token.createSync with token.grantRolesSync to authorize your backend's minting key immediately after deployment, so it can issue supply on customer deposits.
import { } from './viem.config'
const { } = await ..({
: 'USD',
: 'My Company USD',
: 'CUSD',
})
const { } = await ..({
: ['issuer'],
: '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
,
})
.('Issuer granted:', [0].)
Issuer granted: trueimport { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Pin the Token Address Across Environments
Pass a fixed salt so redeploys with identical parameters land at a predictable address, letting downstream systems allowlist the token ahead of deployment.
import { } from './viem.config'
const { } = await ..({
: 'USD',
: 'My Company USD',
: '0x0000000000000000000000000000000000000000000000000000000000000001',
: 'CUSD',
})
.('Address:', )
Address: 0x20c0000000000000000000000000000000000004import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Return Value
type ReturnType = {
/** Created token address. */
token: Address
/** Token name. */
name: string
/** Token symbol. */
symbol: string
/** Currency (e.g. "USD"). */
currency: string
/** Quote token address. */
quoteToken: Address
/** Admin address. */
admin: Address
/** Unique salt. */
salt: Hex
/** Transaction receipt. */
receipt: TransactionReceipt
}Parameters
admin
- Type:
Account | Address - Default:
client.account
Admin address for the token. Required when the Client has no account.
currency
- Type:
string
Currency code for the token (e.g. "USD").
logoURI
- Type:
string
Logo URI for the token. Requires a T5-enabled Tempo chain.
name
- Type:
string
Name of the token.
quoteToken
- Type:
Address | bigint
Quote token address or ID. Defaults to pathUSD.
salt
- Type:
Hex - Default:
Hex.random(32)
Unique salt for deterministic token address generation.
symbol
- Type:
string
Symbol of the token.
account (optional)
- Type:
Account | Address
Account that will be used to send the transaction.
feePayer (optional)
- Type:
Account | boolean
Fee payer for the transaction (TIP-1 gas sponsorship).
Pass true to defer the fee token to an external fee payer (e.g. a relay), or a local Account to co-sign the transaction as the fee payer.
feeToken (optional)
- Type:
Address | bigint
Fee token for the transaction.
Can be an unpaused USD-denominated TIP-20 token address or ID.
gas (optional)
- Type:
bigint
Gas limit for the transaction.
keyAuthorization (optional)
- Type:
KeyAuthorization
Signed key authorization to include with the transaction, authorizing an access key to act for the sending account.
maxFeePerGas (optional)
- Type:
bigint
Max fee per gas for the transaction.
maxPriorityFeePerGas (optional)
- Type:
bigint
Max priority fee per gas for the transaction.
nonce (optional)
- Type:
number
Nonce for the transaction.
nonceKey (optional)
- Type:
'expiring' | 'random' | bigint
Nonce key for the transaction (TIP-1009 2D nonces).
Use 'expiring' to select an expiring nonce, which enables concurrent transaction submission without nonce ordering. Use 'random' to select a random key.
throwOnReceiptRevert (optional)
- Type:
boolean - Default:
true
Whether a Sync action throws when the receipt reports a revert.
validAfter (optional)
- Type:
number
Unix timestamp after which the transaction can be included.
validBefore (optional)
- Type:
number
Unix timestamp before which the transaction must be included.