npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@1o1art/sdk

v1.1.1

Published

1of1 creation on-chain NFTs with delegation cli preview

Downloads

29

Readme

Introduction

1o1.art is a no-code NFT creator platform that empowers artists and businesses to create, manage and upgrade NFT smart contracts. This is the developer sdk, that can be used in conjuntion with the app, to manage, mint, and update your NFTs. You can build your own platform on top of 1o1, using the sdk.

Let's discover 1o1.art sdk in less than 5 minutes.

Getting Started

Get started by installing the sdk client.

What you'll need

  • Node.js version 16.18 or above:
    • When installing Node.js, you are recommended to check all checkboxes related to dependencies.

Install the 1o1art sdk

mkdir 1o1-first-project
cd 1o1-first-project/
npm install @1o1art/sdk
# install dotenv for convenience
npm install dotenv

Add environment variables

Let's write down a few environment variables, for this example we're using the default hardhat private key and an infura rpc url that we setup for this example. Be sure to replace PRIV_KEY= with your own private key without the 0x prefix.

touch .env
# Add the following to your environment variables

#Add your private key
PRIV_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
# Any RPC URL node can be used for a supported network. Replace this with your own key/endpoint
RPC_URL=https://polygon-mumbai.infura.io/v3/0552fa11cf9f4c78afaf923bb1c9389e

#Mantle Testnet Example
# 1O1_RPC_URL=https://rpc.testnet.mantle.xyz

Let's get some testnet crypto

Go here to grab some testnet matic from a faucet: https://mumbaifaucet.com/

Example Code

// add index.ts inside the 1o1-first-project/ directory
import { ClientFactory, lib, NftTokenBuilder } from "@1o1art/sdk";
import * as dotenv from "dotenv";

dotenv.config();

// Remember to add your own private key
const PRIV_KEY = process.env.PRIV_KEY;
const RPC_URL = process.env.RPC_URL;
if (!PRIV_KEY) throw "missing private key";
if (!RPC_URL) throw "missing rpc url";

const main = async () => {
  const client = await ClientFactory.makeClient(PRIV_KEY, RPC_URL);
  console.log("made client");

  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");
  console.log(`retrieved facets ${contractFacets.length}`);

  console.log("deploying contract");
  // 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: "API",
    })
    .deploy();

  console.log("deployed contract");

  // Prepare to create a token
  const nftTokenBuilder = new NftTokenBuilder(
    nftContractBuilder.signer,
    contractAddr
  );

  // This can be any address you'd like to mint to
  const mintToAddress = nftContractBuilder.signer.address;

  const tokenID = await nftTokenBuilder
    .setImage(
      "ipfs://QmNoDT3M1FfF7d3Pd9DkBfzz8NxHueeudWBPe9owt1PnRM",
      "offchain"
    )
    .setAnimation(
      "ipfs://QmTwnLtm7TkmaYJFrYFvsupedP3n51vu6czmVKiED5GyAX",
      "offchain"
    )
    .setDesc("This is my NFT")
    .setName("My NFT")
    .setAttributes({ key: "value", otherKey: "value" })
    .mint(mintToAddress);

  // get access to the recently launch NFT Contract
  const { nftContract } = await client.getNftContractData(contractAddr);

  // Use the contract to get the tokenURI aka the token Metadata
  const tokenURIBase64Encoded = await nftContract.tokenURI(tokenID);

  // get the token Metadata for the minted token
  let tokenMetadata: lib.token.TokenMetadata = JSON.parse(
    lib.utils.convertTokenUriData(tokenURIBase64Encoded)
  ) as lib.token.TokenMetadata;

  console.log("Minted NFT - Token ID: ", tokenID);
  console.log("Minted NFT - Contract Addr: ", contractAddr);
  console.log(
    `Minted NFT - Token Metadata: ${JSON.stringify(tokenMetadata, null, 2)}`
  );
};
try {
  main();
} catch (e) {
  console.log(e);
  console.log("Remember to replace the private key with your own");
}

Run the typescript example via

npx ts-node index.ts

JS Example

// add index.ts inside the 1o1-first-project/ directory
const { ClientFactory, lib, NftTokenBuilder } = require("@1o1art/sdk");
const dotenv = require("dotenv");

dotenv.config();

// Remember to add your own private key
const PRIV_KEY = process.env.PRIV_KEY;
const RPC_URL = process.env.RPC_URL;
if (!PRIV_KEY) throw "missing private key";
if (!RPC_URL) throw "missing rpc url";


const main = async () => {
  const client = await ClientFactory.makeClient(PRIV_KEY, RPC_URL);
  console.log("made client");

  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");
  console.log(`retrieved facets ${contractFacets.length}`);

  console.log("deploying contract");
  // 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: "API",
    })
    .deploy();

  console.log("deployed contract");

  // Prepare to create a token
  const nftTokenBuilder = new NftTokenBuilder(
    nftContractBuilder.signer,
    contractAddr
  );

  // This can be any address you'd like to mint to
  const mintToAddress = nftContractBuilder.signer.address;

  const tokenID = await nftTokenBuilder
    .setImage(
      "ipfs://QmNoDT3M1FfF7d3Pd9DkBfzz8NxHueeudWBPe9owt1PnRM",
      "offchain"
    )
    .setAnimation(
      "ipfs://QmTwnLtm7TkmaYJFrYFvsupedP3n51vu6czmVKiED5GyAX",
      "offchain"
    )
    .setDesc("This is my NFT")
    .setName("My NFT")
    .setAttributes({ key: "value", otherKey: "value" })
    .mint(mintToAddress);

  // get access to the recently launch NFT Contract
  const { nftContract } = await client.getNftContractData(contractAddr);

  // Use the contract to get the tokenURI aka the token Metadata
  const tokenURIBase64Encoded = await nftContract.tokenURI(tokenID);

  // get the token Metadata for the minted token
  let tokenMetadata: lib.token.TokenMetadata = JSON.parse(
    lib.utils.convertTokenUriData(tokenURIBase64Encoded)
  ) as lib.token.TokenMetadata;

  console.log("Minted NFT - Token ID: ", tokenID);
  console.log("Minted NFT - Contract Addr: ", contractAddr);
  console.log(
    `Minted NFT - Token Metadata: ${JSON.stringify(tokenMetadata, null, 2)}`
  );
};
try {
  main();
} catch (e) {
  console.log(e);
  console.log("Remember to replace the private key with your own")
}

Run the javascript example via

node index.js

Learn More

Checkout our docs page to learn more about how 1o1 works. https://docs.1o1.art