Mint Stablecoins
Create new tokens by minting them to a specified address. Minting increases the total supply of your stablecoin.
Steps
Create a Stablecoin
Before you can mint tokens, you need to create a stablecoin. Follow the Create a Stablecoin guide to deploy your token.
Once you've created your token, you can proceed to grant the issuer role and mint tokens.
Grant the Issuer Role
Assign the issuer role to the address that will mint tokens. Minting requires the ISSUER_ROLE.
Grant Issuer Role
demoimport React from 'react'
import { } from 'wagmi/tempo'
import { } from '@tanstack/react-query'
export function () {
const = ()
const = '0x...' // Your token address
const = '0x...' // Address to grant the issuer role
const = ..({
: {
() {
.({ : ['hasRole'] })
},
},
})
const = async () => {
await .({
: ,
: ['issuer'],
: ,
: '0x20c0000000000000000000000000000000000001',
})
}
return (
<
={.}
={}
="button"
>
{. ? 'Granting...' : 'Grant Issuer Role'}
</> {}
)
}Mint Tokens to a Recipient
Now that the issuer role is granted, you can mint tokens to any address.
Mint Tokens
demoimport React from 'react'
import { } from 'wagmi/tempo'
import { } from 'wagmi'
import { , , } from 'viem'
import { } from '@tanstack/react-query'
export function () {
const { } = ()
const = ()
const = '0x...' // Your token address
const [, ] = React.<string>('')
const [, ] = React.<string>('')
const { : } = ..({
: ,
})
const = ..({
: {
() {
.({ : ['getBalance'] })
},
},
})
const = () => {
if (! || ! || !) return
.({
: ('100', .),
: as `0x${string}`,
: ,
: ? ((), { : 32 }) : ,
: '0x20c0000000000000000000000000000000000001',
})
}
return (
<>
<>
<>Recipient address</>
<
="text"
={}
={() => (..)}
="0x..."
/>
</>
<>
<>Memo (optional)</>
<
="text"
={}
={() => (..)}
="INV-12345"
/>
</>
<
={! || .}
={}
="button"
>
{. ? 'Minting...' : 'Mint'}
</>
</>
)
}Recipes
Burning Stablecoins
To decrease supply, you can burn tokens from your own balance. Burning requires the ISSUER_ROLE and sufficient balance in the caller's account.
Burn Your Token
demoimport React from 'react'
import { } from 'wagmi/tempo'
import { } from 'wagmi'
import { , , } from 'viem'
import { } from '@tanstack/react-query'
export function () {
const { } = ()
const = ()
const = '0x...' // Your token address
const [, ] = React.<string>('')
const { : } = ..({
: ,
})
const = ..({
: {
() {
.({ : ['getBalance'] })
},
},
})
const = () => {
if (! || ! || !) return
.({
: ('100', .),
: ,
: ? ((), { : 32 }) : ,
: '0x20c0000000000000000000000000000000000001',
})
}
return (
<>
<>
<>Memo (optional)</>
<
="text"
={}
={() => (..)}
="INV-12345"
/>
</>
<
={! || .}
={}
="button"
>
{. ? 'Burning...' : 'Burn'}
</>
</>
)
}Best Practices
Monitor Supply Caps
If your token has a supply cap set, any mint() or mintWithMemo() call that would exceed the cap will revert with SupplyCapExceeded(). You must either:
- Burn tokens to reduce total supply below the cap
- Increase the supply cap (requires
DEFAULT_ADMIN_ROLE) - Remove the cap entirely by setting it to
type(uint256).max
Use getMetadata to check your token's total supply before minting.
Role Separation
Assign the issuer role to dedicated treasury or minting addresses separate from your admin address. This enhances security by limiting the privileges of any single address.