NFT Collection
Deploy a full-featured ERC-721 NFT collection with enumeration, metadata, royalties, and batch operations.
When to Use
- Digital art — deploy a collection with royalties and individual metadata per NFT
- Gaming items — unique in-game assets with on-chain ownership
- Membership passes — NFT-gated access to communities and services
- Real-world asset certificates — digital proof of ownership with metadata
Deploy an ERC-721 Contract
const collection = await urblock.tokens.create({
name: "Pixel Punks",
symbol: "PPNK",
standard: "ERC721",
network: "polygon_amoy",
features: {
mintable: true,
burnable: true,
pausable: true,
royalty: true,
},
default_royalty: {
receiver: "0xRoyaltyReceiver...",
fee_basis_points: 500, // 5%
},
idempotency_key: "nft-collection-001",
});
Mint NFTs
const tx = await urblock.transactions.mint(collection.id, {
to: "0xCollector...",
amount: "1",
token_uri: "ipfs://QmHash.../1.json",
idempotency_key: "mint-nft-1",
});
List NFTs
const nfts = await urblock.tokens.listNfts(collection.id, { limit: 20 });
for (const nft of nfts.data) {
console.log(nft.nft_token_id, nft.owner, nft.token_uri);
}
Get NFT Details
const nft = await urblock.tokens.getNft(collection.id, 1);
console.log(nft.owner);
console.log(nft.token_uri);
Update Metadata
const tx = await urblock.transactions.setTokenUri(collection.id, 1, {
token_uri: "ipfs://QmNewHash.../1.json",
idempotency_key: "update-uri-001",
});
Set Royalties
Default Royalty (all tokens)
const tx = await urblock.transactions.setRoyalty(collection.id, {
receiver: "0xNewReceiver...",
fee_basis_points: 750, // 7.5%
idempotency_key: "set-royalty-001",
});
Per-Token Royalty
const tx = await urblock.transactions.setTokenRoyalty(collection.id, 1, {
receiver: "0xArtist...",
fee_basis_points: 1000, // 10%
idempotency_key: "token-royalty-001",
});
Transfer an NFT
const tx = await urblock.transactions.transfer(collection.id, {
from: "0xOwner...",
to: "0xNewOwner...",
nft_token_id: "1",
idempotency_key: "transfer-nft-001",
});
Burn an NFT
const tx = await urblock.transactions.burn(collection.id, {
from: "0xHolder...",
nft_token_id: "1",
idempotency_key: "burn-nft-001",
});
Pause / Unpause
await urblock.tokens.pause(collection.id);
// All transfers blocked
await urblock.tokens.unpause(collection.id);
// Transfers resumed
ERC-1155 Multi-Token
For collections with both fungible and non-fungible token types, use ERC-1155:
const multiToken = await urblock.tokens.create({
name: "Game Items",
symbol: "ITEM",
standard: "ERC1155",
network: "polygon_amoy",
features: { mintable: true, burnable: true, pausable: true },
idempotency_key: "game-items-001",
});
Batch Mint (ERC-1155)
const tx = await urblock.tokens.mintBatch(multiToken.id, {
to: "0xPlayer...",
items: [
{ nft_token_id: 1, amount: "100" },
{ nft_token_id: 2, amount: "50" },
{ nft_token_id: 3, amount: "1" },
],
idempotency_key: "batch-mint-001",
});
Batch Transfer (ERC-1155)
const tx = await urblock.tokens.transferBatch(multiToken.id, {
from: "0xSender...",
to: "0xRecipient...",
items: [
{ nft_token_id: 1, amount: "10" },
{ nft_token_id: 2, amount: "5" },
],
idempotency_key: "batch-transfer-001",
});
Next Steps
- Token Bound Accounts — give your NFTs their own wallets
- Advanced Token Features — SBT, specialized token standards
- Gas Optimization — use Solady variants for cheaper deploys
- Webhook Integration — get notified on mint/transfer events