Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@darenft-labs/nft2-client
Advanced tools
Readme
This is DareNFT 2.0 Protocol's officially supported node.js client library.
Install by yarn
yarn add @darenft-labs/nft2-client
or using npm
npm add @darenft-labs/nft2-client
Note: node version should be greater than 16.14
import { NFT2Client } from "@darenft-labs/nft2-client";
const apiKey = 'xxx'; // must get from NT2 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:
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)
Example get list NFTs of a wallet on Ether:
const chainId = 1; // chain Ether
const nft2Contract = nft2Client.getNFT2Contract(chainId);
const nfts = await nft2Contract.getNFTsByOwner(ownerAddress, {limit: 20, offset: 0});
console.log('nft: ', nfts);
Example get NFT data saved on Data Registry:
const chainId = 1; // chain Ether
const dataRegistry = nft2Client.getNFT2DataRegistry(chainId);
const datas = await dataRegistry.getNFTMetaData(
'0xabcd', // NFT address
'0' // token ID
);
console.log('datas: ', datas);
Install libs
yarn install
Edit .env
file in /samples
folder
cp .env.example .env
Run 1 sample
yarn ts-node samples/[file_name].ts
yarn test -g protocolclient
Run with debug logging
yarn test-debug -g protocolclient
Testing a single file
yarn test-single test/xxx.ts
yarn test-debug test/
FAQs
NFT2 Client Library for Node.js
The npm package @darenft-labs/nft2-client receives a total of 75 weekly downloads. As such, @darenft-labs/nft2-client popularity was classified as not popular.
We found that @darenft-labs/nft2-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.