Mint and Transfer Tokens
After deploying a token, you can mint new tokens to addresses and transfer them between wallets.
Prerequisites
- A deployed token (
tok_...) withmintable: true - A wallet with the MINTER_ROLE
Minting
Mint ERC-20 Tokens
const tx = await urblock.transactions.mint("tok_abc123", {
to: "0xRecipient...",
amount: "1000000000000000000000", // 1000 tokens (18 decimals)
idempotency_key: "mint-001",
});
Mint an ERC-721 NFT
For ERC-721 tokens, amount is typically "1" and include a token_uri:
const tx = await urblock.transactions.mint("tok_abc123", {
to: "0xRecipient...",
amount: "1",
token_uri: "ipfs://QmHash.../metadata.json",
idempotency_key: "mint-nft-001",
});
Mint ERC-1155 Tokens
const tx = await urblock.transactions.mint("tok_abc123", {
to: "0xRecipient...",
amount: "100",
nft_token_id: 1,
idempotency_key: "mint-1155-001",
});
Transferring
Transfer ERC-20 Tokens
const tx = await urblock.transactions.transfer("tok_abc123", {
from: "0xSender...",
to: "0xRecipient...",
amount: "500000000000000000", // 0.5 tokens
idempotency_key: "transfer-001",
});
Transfer an ERC-721 NFT
const tx = await urblock.transactions.transfer("tok_abc123", {
from: "0xSender...",
to: "0xRecipient...",
nft_token_id: "1",
idempotency_key: "transfer-nft-001",
});
Transfer ERC-1155 Tokens
const tx = await urblock.transactions.transfer("tok_abc123", {
from: "0xSender...",
to: "0xRecipient...",
nft_token_id: "1",
amount: "10",
idempotency_key: "transfer-1155-001",
});
Burning
Burn ERC-20 Tokens
const tx = await urblock.transactions.burn("tok_abc123", {
from: "0xHolder...",
amount: "100000000000000000", // 0.1 tokens
idempotency_key: "burn-001",
});
Burn an ERC-721 NFT
const tx = await urblock.transactions.burn("tok_abc123", {
from: "0xHolder...",
nft_token_id: "1",
idempotency_key: "burn-nft-001",
});
Approvals
Approve a Spender (ERC-20)
const tx = await urblock.transactions.approve("tok_abc123", {
owner: "0xOwner...",
spender: "0xSpender...",
amount: "1000000000000000000",
idempotency_key: "approve-001",
});
Transfer on Behalf (transferFrom)
const tx = await urblock.transactions.transferFrom("tok_abc123", {
spender: "0xSpender...",
from: "0xOwner...",
to: "0xRecipient...",
amount: "500000000000000000",
idempotency_key: "transfer-from-001",
});
Set Approval for All (ERC-721 / ERC-1155)
const tx = await urblock.transactions.setApprovalForAll("tok_abc123", {
owner: "0xOwner...",
operator: "0xOperator...",
approved: true,
idempotency_key: "approval-all-001",
});
Important Notes
- All
amountvalues are strings in the token's smallest unit (wei for 18-decimal tokens) - All blockchain operations are asynchronous — they return with
status: "pending" - Use
idempotency_keyto prevent duplicate operations - NFT token IDs (
nft_token_id) are numbers when minting, strings when transferring/burning
Next Steps
- Token Standards — understand all 10 supported standards
- Async Operations — how pending transactions work
- Webhook Integration — get notified when operations complete
- Batch Operations — mint to multiple addresses in one tx
- Roles — manage MINTER_ROLE and BURNER_ROLE