DERA chain docs
  • Introduction
  • NFT2.0
    • Introduction
    • Architecture
    • Concepts
      • Collection
      • NFT2.0
      • Data Registry
      • Derivative NFT
      • Derived Account
      • Token Bound Account (aka TBA)
    • Smart Contracts
      • Interfaces
        • Factory
        • Dynamicity
        • Derivability
        • Cross chain ability
      • Use cases
        • Create collection
        • Mint NFT2.0
        • Create Data registry
        • Write onchain data
        • Retrieve onchain data
        • Mint Derivative NFT2.0
        • Create TBA
    • SDK
      • Setup
        • Create Console Account
        • Manage API key
        • Set up metadata schema
        • Initialize the SDK
      • API reference
        • Get List Collection
        • Get List Collection By Owner
        • Get Collection Info
        • Get List NFT By Collection
        • Get List NFT By Owner
        • Get List Derivative NFT By Original
        • Get NFT Info
        • Get List Data Registry
        • Get Data Registry By Owner
        • Get Data Registry Info
        • Get NFT onchain data
        • Get NFT protocol-scoped onchain data
        • Get User Freemint Info
        • Get Claim Token Uri Info
        • Upload JSON Uri Data To IPFS
        • Generate Presigned URL To Upload Image (IPFS)
        • Utility Functions
    • App guide
      • NFT2Scan
        • Create Collection
        • Mint NFT2.0
        • Mint Derivative NFT2.0
      • NFT2Console
        • Create Dapp
        • Register data schema
        • Manage API keys
        • Manage onchain data
    • References
      • Links
  • Bridge
    • Introduction
    • Bridge Token
    • Bridge NFT
  • Staking
    • Introduction
    • Validate
    • Delegate
  • Smart Contracts
    • EVM compatibility
    • Hardhat
    • Foundry
    • Account Abstraction
    • SubQuery Indexer
    • SAFE multisign
  • Nodes & Validators
    • Run a Node
    • Become a Validator
Powered by GitBook
On this page
  • Installation
  • Configuration
  • Parameters
  1. NFT2.0
  2. SDK
  3. Setup

Initialize the SDK

Installation

npm add @darenft-labs/nft2-client

Configuration

import { NFT2Client } from "@darenft-labs/nft2-client";
 
const apiKey = 'xxx'; // API Key from NFT2 console
const nft2Client = new NFT2Client(apiKey);
 
await nft2Client.initialize().then(() => {
    console.log('Client init success: ', nft2Client);
});

The SDK will automatic load configuration from API server (GET: /configs/internal-config). However, you can set your alternative configuration as you want.

import { ChainConfig } from "@darenft-labs/nft2-client";
 
const configs: ChainConfig[] = [{
  chainId: 1,
  providerUrl: "https://eth-mainnet.nodereal.io/v1/xxx",
  factoryAddress: "0xabcd",
  subQueryEndpoint: "https://api.subquery.network/sq/xxx"
}]
nft2Client.updateConfig(configs)

Parameters

NFT2Client:

  • apiKey (string): Account API key.

  • apiEndpoint (string): endpoint of protocol API. Optional. Using for multiple environment.

ChainConfig:

  • chainId (number): chain id of current chain.

  • providerUrl (string): RPC endpoint for current chain.

  • factoryAddress (string): Factory contract address on current chain.

  • subQueryEndpoint (string): Subquery endpoint for current chain.

NOTE: when update config manually, all chainId, providerUrl, factoryAddress, subQueryEndpoint is required. If some chains hadn't configured, you couldn't call SDK function for those chain.

PreviousSet up metadata schemaNextAPI reference

Last updated 7 months ago