Module

NFT ERC-1155 — 2–10 credits

Interact with ERC-1155 multi-token contracts. ERC-1155 allows a single contract to manage multiple token types (both fungible and non-fungible). Query balances, metadata URIs, and transfer tokens.

API Key
balance()
GET 2 credits API Key

Get the balance of a single ERC-1155 token ID for a specific address.

Parameters

NameTypeRequiredDescription
$contractstringYesERC-1155 contract address
$addressstringYesWallet address to check
$tokenIdintYesToken ID to query
$network?stringNoNetwork name. Defaults to WEB3_DEFAULT_NETWORK

Example

$result = Web3Api::nft1155()->balance(
    contract: '0xd07dc4262BCDbf85190C01c996b4C06a461d2430',
    address:  '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
    tokenId:  1,
    network:  'polygon',
);

Response

[
  'contract' => '0xd07dc4262BCDbf85190C01c996b4C06a461d2430',
  'address'  => '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
  'token_id' => 1,
  'balance'  => 10,    // holds 10 copies of token ID 1
]
balanceBatch()
POST 2 credits API Key

Get balances for multiple ERC-1155 token IDs for a single address in one call.

Parameters

NameTypeRequiredDescription
$contractstringYesERC-1155 contract address
$addressstringYesWallet address to check
$tokenIdsint[]YesArray of token IDs to query
$network?stringNoNetwork name. Defaults to WEB3_DEFAULT_NETWORK

Example

$balances = Web3Api::nft1155()->balanceBatch(
    contract:  '0xd07dc4262BCDbf85190C01c996b4C06a461d2430',
    address:   '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
    tokenIds:  [1, 2, 3, 5, 10],
    network:   'polygon',
);

// $balances['1']  => 10
// $balances['2']  => 5
// $balances['3']  => 0
// $balances['5']  => 1
// $balances['10'] => 0

Response

{ "1": 10, "2": 5, "3": 0, "5": 1, "10": 0 }
uri()
GET 2 credits API Key

Retrieve the metadata URI for a specific ERC-1155 token ID. The URI may contain {id} as a placeholder per the ERC-1155 spec.

Parameters

NameTypeRequiredDescription
$contractstringYesERC-1155 contract address
$tokenIdintYesToken ID
$network?stringNoNetwork name. Defaults to WEB3_DEFAULT_NETWORK

Example

$result = Web3Api::nft1155()->uri(
    contract: '0xd07dc4262BCDbf85190C01c996b4C06a461d2430',
    tokenId:  1,
    network:  'polygon',
);

Response

[
  'contract' => '0xd07dc4262BCDbf85190C01c996b4C06a461d2430',
  'token_id' => 1,
  'uri'      => 'https://metadata.example.com/{id}.json',
]
transfer()
POST 10 credits API Key

Transfer a quantity of an ERC-1155 token from one address to another using safeTransferFrom.

Parameters

NameTypeRequiredDescription
$contractAddressstringYesERC-1155 contract address
$fromAddressstringYesSender's wallet address
$privateKey?stringNoSender's private key. Pass null to use the stored managed wallet
$toAddressstringYesRecipient's wallet address
$tokenIdintYesToken ID to transfer
$amountintYesQuantity to transfer
$network?stringNoNetwork name. Defaults to WEB3_DEFAULT_NETWORK
$datastringNoAdditional data bytes to pass to recipient (default: "0x")

Example

$tx = Web3Api::nft1155()->transfer(
    contractAddress: '0xd07dc4262BCDbf85190C01c996b4C06a461d2430',
    fromAddress:     '0xSENDER_ADDRESS',
    privateKey:      '0xSENDER_PRIVATE_KEY',
    toAddress:       '0xRECEIVER_ADDRESS',
    tokenId:         1,
    amount:          5,       // send 5 copies of token ID 1
    network:         'polygon',
    data:            '0x',    // optional extra data
);

Response

[
  'tx_hash' => '0xabcdef1234567890...',
  'status'  => 'pending',
]