Skip to content
On this page

Getting Started

Install the Mirror NFT SDK

$ npm install @cmirrorxyz/mirror-nft-sdk

Using the SDK

Import the SDK and create a token.

ts
import { chainId, rpcURL } from "config.ts";
import { MirrorSDK } from "@cmirrorxyz/mirror-nft-sdk";
import type { ERC721TokenConfig } from "@cmirrorxyz/mirror-nft-sdk";

const sdk = new MirrorSDK(chainId, rpcURL);

const tokenConfig: ERC721TokenConfig = {
  name: "Awesome name",
  symbol: "Awesome symbol",
};

const transactionData = sdk.factory.getTransactionData(tokenConfig);
ts
export const chainId: number = 31337;
export const rpcURL: string = "127.0.0.1:8545"

getTransactionData encodes all the necessary calls and returns all the values needed to create the token, including where to submit the transaction.

ts
// transactionData
{
   value:"0",
   to:"0x2878156311A15bC50E3a4Def2148fB5fD8841641",
   data:"0x0162ea58000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000085328000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000036e616d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000373796d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000049b08a22f00000000000000000000000000000000000000000000000000000000"
}

The power of this pattern reveals itself more with more complex token configuration. See ERC721TokenConfig [link] definition.