Skip to main content

TokensResource

Access via urblock.tokens.

Methods

create(params)

Deploy a new token contract.

const token = await urblock.tokens.create({
name: "My Token",
symbol: "MTK",
standard: "ERC20",
network: "polygon_amoy",
initial_supply: "1000000000000000000000000",
idempotency_key: "deploy-mtk-001",
});

Returns: TokenResponse


list(params?)

List all deployed tokens.

const tokens = await urblock.tokens.list({ limit: 10 });

Returns: ListResponse<TokenListItem>


retrieve(id)

Get a single token by ID.

const token = await urblock.tokens.retrieve("tok_abc123");

Returns: TokenResponse


getSupply(id)

Get the total supply of a token.

const supply = await urblock.tokens.getSupply("tok_abc123");

Returns: TokenSupplyResponse


getBalance(id, params)

Get the balance of an address for a token.

const balance = await urblock.tokens.getBalance("tok_abc123", {
address: "0x...",
nft_token_id: "0",
});

Returns: BalanceResponse


getAllowance(id, params)

Get the allowance granted by an owner to a spender.

const allowance = await urblock.tokens.getAllowance("tok_abc123", {
owner: "0x...",
spender: "0x...",
});

Returns: AllowanceResponse


getApproved(id, params)

Get the approved address for a specific NFT token ID (ERC-721).

const approved = await urblock.tokens.getApproved("tok_abc123", {
nft_token_id: "1",
});

Returns: ApprovedAddressResponse


isApprovedForAll(id, params)

Check if an operator is approved for all tokens of an owner.

const result = await urblock.tokens.isApprovedForAll("tok_abc123", {
owner: "0x...",
operator: "0x...",
});

Returns: ApprovalForAllResponse


getNft(id, nftTokenId)

Get details of a specific NFT within a token contract.

const nft = await urblock.tokens.getNft("tok_abc123", 1);

Returns: NftResponse


listNfts(id, params?)

List NFTs in a token contract.

const nfts = await urblock.tokens.listNfts("tok_abc123", { limit: 20 });

Returns: ListResponse<NftResponse>


getTokenUri(id, params)

Get the token URI for a specific NFT token ID.

const uri = await urblock.tokens.getTokenUri("tok_abc123", {
nft_token_id: "1",
});

Returns: TokenUriResponse


tokenExists(id, params)

Check if a specific token ID exists (ERC-1155).

const exists = await urblock.tokens.tokenExists("tok_abc123", {
nft_token_id: "1",
});

Returns: TokenExistsResponse


balanceOfBatch(id, params)

Get balances for multiple accounts/token IDs (ERC-1155).

const balances = await urblock.tokens.balanceOfBatch("tok_abc123", {
accounts: "0xAAA...,0xBBB...",
ids: "1,2",
});

Returns: BalanceBatchResponse


pause(id)

Pause a token contract (requires PAUSABLE feature).

const token = await urblock.tokens.pause("tok_abc123");

Returns: TokenResponse


unpause(id)

Unpause a token contract.

const token = await urblock.tokens.unpause("tok_abc123");

Returns: TokenResponse


mintBatch(id, params)

Batch mint tokens (ERC-1155).

const tx = await urblock.tokens.mintBatch("tok_abc123", {
to: "0x...",
items: [
{ nft_token_id: 1, amount: "100" },
{ nft_token_id: 2, amount: "200" },
{ nft_token_id: 3, amount: "50" },
],
idempotency_key: "batch-mint-001",
});

Returns: TransactionResponse


transferBatch(id, params)

Batch transfer tokens (ERC-1155).

const tx = await urblock.tokens.transferBatch("tok_abc123", {
from: "0x...",
to: "0x...",
items: [
{ nft_token_id: 1, amount: "10" },
{ nft_token_id: 2, amount: "20" },
],
idempotency_key: "batch-transfer-001",
});

Returns: TransactionResponse


burnBatch(id, params)

Batch burn tokens (ERC-1155).

const tx = await urblock.tokens.burnBatch("tok_abc123", {
from: "0x...",
items: [
{ nft_token_id: 1, amount: "5" },
{ nft_token_id: 2, amount: "10" },
],
idempotency_key: "batch-burn-001",
});

Returns: TransactionResponse


getLocked(id, params)

Check if a specific NFT token ID is locked (ERC-5192 / Soulbound).

const result = await urblock.tokens.getLocked("tok_abc123", {
nft_token_id: "1",
network: "polygon_amoy",
});

console.log(result.locked); // true

Returns: LockedResponse


getRoyaltyInfo(id, params)

Get royalty information for a token sale (ERC-2981).

const royalty = await urblock.tokens.getRoyaltyInfo("tok_abc123", {
nft_token_id: "1",
sale_price: "1000000000000000000",
network: "polygon_amoy",
});

console.log(royalty.receiver); // "0x..."
console.log(royalty.royalty_amount); // "50000000000000000"

Returns: RoyaltyInfoResponse


supportsInterface(id, params)

Check if a token contract supports a specific ERC-165 interface.

const result = await urblock.tokens.supportsInterface("tok_abc123", {
interface_id: "0x80ac58cd", // ERC-721
network: "polygon_amoy",
});

console.log(result.supported); // true

Returns: SupportsInterfaceResponse


getTokenByIndex(id, params)

Get a token ID by its index in the global enumeration (ERC-721 Enumerable).

const result = await urblock.tokens.getTokenByIndex("tok_abc123", {
index: "0",
network: "polygon_amoy",
});

console.log(result.nft_token_id); // "1"

Returns: TokenByIndexResponse


getTokenOfOwnerByIndex(id, params)

Get a token ID owned by an address at a specific index (ERC-721 Enumerable).

const result = await urblock.tokens.getTokenOfOwnerByIndex("tok_abc123", {
owner: "0x1234...",
index: "0",
network: "polygon_amoy",
});

console.log(result.nft_token_id); // "42"

Returns: TokenOfOwnerByIndexResponse


transferOwnership(id, params)

Transfer ownership of the token contract to a new address.

const tx = await urblock.tokens.transferOwnership("tok_abc123", {
new_owner: "0xNewOwner...",
idempotency_key: "transfer-ownership-001",
});

Returns: TransferOwnershipResponse


getFactoryTotalDeployed(params)

Get the total number of tokens deployed via the factory contract on a network.

const result = await urblock.tokens.getFactoryTotalDeployed({
network: "polygon_amoy",
});

console.log(result.total_deployed); // 42

Returns: FactoryTotalDeployedResponse