Module
NFT (ERC-721) — 2–10 credits
Interact with ERC-721 non-fungible tokens: retrieve metadata and ownership info (2 credits), check owner balances (2 credits), and transfer tokens between addresses (10 credits).
API Key
info()
GET
2 credits
API Key
Retrieve metadata, current owner, and token URI for a specific ERC-721 token.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
$contractAddress | string | Yes | ERC-721 contract address |
$tokenId | int | Yes | Token ID (integer) |
$network | ?string | No | Network name. Defaults to WEB3_DEFAULT_NETWORK |
Example
$nft = Web3Api::nft()->info(
contractAddress: '0xBCE3781ae7Ca1a5e050Bd9C4c77369867eBc307e',
tokenId: 42,
network: 'polygon',
);
Response
[
'contract' => '0xBCE3781ae7Ca1a5e050Bd9C4c77369867eBc307e',
'token_id' => 42,
'owner' => '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
'token_uri' => 'ipfs://QmXyz.../42.json',
'metadata' => [
'name' => 'Token #42',
'description' => 'A unique digital collectible',
'image' => 'ipfs://QmXyz.../42.png',
'attributes' => [/* ... */],
],
]
balance()
GET
2 credits
API Key
Get the total number of ERC-721 tokens held by an address for a given contract.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
$contractAddress | string | Yes | ERC-721 contract address |
$ownerAddress | string | Yes | Wallet address to check |
$network | ?string | No | Network name. Defaults to WEB3_DEFAULT_NETWORK |
Example
$result = Web3Api::nft()->balance(
contractAddress: '0xBCE3781ae7Ca1a5e050Bd9C4c77369867eBc307e',
ownerAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
network: 'polygon',
);
echo $result['balance']; // 3 — owns 3 tokens from this collection
Response
[
'contract' => '0xBCE3781ae7Ca1a5e050Bd9C4c77369867eBc307e',
'owner' => '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
'balance' => 3,
]
transfer()
POST
10 credits
API Key
Transfer an ERC-721 token from one address to another using safeTransferFrom. Requires the sender's private key.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
$contractAddress | string | Yes | ERC-721 contract address |
$fromAddress | string | Yes | Current token owner's address |
$privateKey | ?string | No | Private key of the current owner. Pass null to use the stored managed wallet |
$toAddress | string | Yes | Recipient address |
$tokenId | int | Yes | Token ID to transfer |
$network | ?string | No | Network name. Defaults to WEB3_DEFAULT_NETWORK |
Example
$tx = Web3Api::nft()->transfer(
contractAddress: '0xBCE3781ae7Ca1a5e050Bd9C4c77369867eBc307e',
fromAddress: '0xCURRENT_OWNER',
privateKey: '0xOWNER_PRIVATE_KEY',
toAddress: '0xNEW_OWNER',
tokenId: 42,
network: 'polygon',
);
echo $tx['tx_hash']; // "0xabcdef..."
echo $tx['status']; // "pending"
Response
[
'tx_hash' => '0xabcdef1234567890...',
'status' => 'pending',
]