Create a NFT Contract
First configure the SDK client
The first thing we do is create an SDK client. This allows us to setup RPC connections and configurations for interacting with 1o1Art NFT Contract Deployer. We pass in the private key and RPC URL
import { ClientFactory } from "@1o1art/sdk";
// setup the client
const client = ClientFactory.makeClient(PRIVATE_KEY, RPC_URL);
Create the nft contract builder and get contract presets
This allows us to have a simple builder object to help us setup the nft contract we'd like to deploy.
The getPresetFacets
call allows us to get smart contract facets/extensions from 1o1, to be added to our blank
Smart contract. There are two presets "basic" and "delegatable" which is like the basic but also includes delegation
capabilities.
const nftContractBuilder = client.createNftContractBuilder();
// Get the components you'd like to add to your blank smart contract
// basic will load the bare minimum to make a contract, delegatable
// will provide a delegatable ERC721 token
const contractFacets = await client.getPresetFacets("delegatable");
Configure and deploy the NFT
Here we use our builder to then, set a smart contract cover image, the name of the smart contract, symbol and description for the smart contract. The cover image can be an offchain image("we expect ipfs://") or an onchain image, which would need to be base64 encoded see our onchain how to guide. What we get back is the contract address that our NFT has been deployed to.
// Create the contract and set a contract image
const contractAddr = await nftContractBuilder
.setFacets(contractFacets)
.setImage("ipfs://QmNoDT3M1FfF7d3Pd9DkBfzz8NxHueeudWBPe9owt1PnRM", "offchain")
.setMetadata({
name: "My NFT",
description: "This is my NFT",
symbol: "FIRST",
})
.deploy();
console.log(contractAddr);
Putting it all together
import { ClientFactory } from "@1o1art/sdk";
// setup the client
const client = ClientFactory.makeClient(PRIVATE_KEY, RPC_URL);
const nftContractBuilder = client.createNftContractBuilder();
// Get the components you'd like to add to your blank smart contract
// basic will load the bare minimum to make a contract, delegatable
// will provide a delegatable ERC721 token
const contractFacets = await client.getPresetFacets("delegatable");
// Create the contract and set a contract image
const contractAddr = await nftContractBuilder
.setFacets(contractFacets)
.setImage("ipfs://QmNoDT3M1FfF7d3Pd9DkBfzz8NxHueeudWBPe9owt1PnRM", "offchain")
.setMetadata({
name: "My NFT",
description: "This is my NFT",
symbol: "FIRST",
})
.deploy();
console.log(contractAddr);