NFT Management API

NFT Management API

Overview

Endpoints for managing existing NFTs, including retrieving details, updating metadata, transferring ownership, and burning tokens.

Get NFT Details

Retrieve detailed information about a specific NFT.

GET api.bloclabs.com/v1/nfts/{token_id}

Response

{
    "status": "success",
    "data": {
        "token_id": "1234",
        "collection_address": "0x789...def",
        "owner_address": "0x123...abc",
        "token_uri": "ipfs://Qm...",
        "metadata": {
            "name": "Artwork #1",
            "description": "Description of the artwork",
            "image": "ipfs://Qm...",
            "attributes": [
                {
                    "trait_type": "Background",
                    "value": "Blue"
                }
            ]
        },
        "last_transfer_date": "2024-03-15T10:00:00Z",
        "token_standard": "ERC721"
    }
}

Transfer NFT

Transfer an NFT to a new owner.

POST api.bloclabs.com/v1/nfts/{token_id}/transfer

Request

{
    "from_address": "0x123...abc",
    "to_address": "0x789...def",
    "amount": 1,  // Required for ERC1155
    "data": "0x..." // Optional: Additional data for transfer
}

Response

{
    "status": "success",
    "data": {
        "transaction_hash": "0xabc...123",
        "token_id": "1234",
        "collection_address": "0x789...def",
        "from_address": "0x123...abc",
        "to_address": "0x789...def",
        "timestamp": "2024-03-15T10:00:00Z"
    }
}

Burn NFT

Permanently destroy an NFT.

DELETE api.bloclabs.com/v1/nfts/{token_id}

Request

{
    "owner_address": "0x123...abc",
    "amount": 1  // Required for ERC1155
}

Response

{
    "status": "success",
    "data": {
        "transaction_hash": "0xdef...456",
        "token_id": "1234",
        "collection_address": "0x789...def",
        "burned_by": "0x123...abc",
        "burned_at": "2024-03-15T10:00:00Z"
    }
}

Get NFT History

Retrieve the transaction history of an NFT.

GET api.bloclabs.com/v1/nfts/{token_id}/history

Query Parameters

{
    "event_type": "all",    // all, transfer, mint, burn
    "from_date": "2024-01-01",
    "to_date": "2024-03-15",
    "limit": 10,
    "offset": 0
}

Response

{
    "status": "success",
    "data": {
        "events": [
            {
                "event_type": "TRANSFER",
                "from_address": "0x123...abc",
                "to_address": "0x789...def",
                "transaction_hash": "0xghi...789",
                "timestamp": "2024-03-15T10:00:00Z",
                "block_number": 15481234
            }
        ],
        "pagination": {
            "total": 5,
            "limit": 10,
            "offset": 0
        }
    }
}

Error Responses

Token Not Found

{
    "status": "error",
    "message": "NFT not found",
    "code": "TOKEN_NOT_FOUND",
    "data": {
        "token_id": "1234",
        "collection_address": "0x789...def"
    }
}

Unauthorized Transfer

{
    "status": "error",
    "message": "Not authorized to transfer token",
    "code": "UNAUTHORIZED_TRANSFER",
    "data": {
        "owner_address": "0x123...abc",
        "requester_address": "0x456...def"
    }
}

Burn Failed

{
    "status": "error",
    "message": "Failed to burn token",
    "code": "BURN_FAILED",
    "data": {
        "reason": "Token already burned",
        "token_id": "1234"
    }
}

Notes

  • Transfer operations require approval or ownership

  • Burned tokens cannot be recovered

  • History is maintained even after burning

  • ERC1155 tokens require amount specification

  • Transfer events are emitted on-chain

  • Consider gas costs for operations

Last updated

Was this helpful?