Skip to content

superrare/rare-sdk-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rare-sdk-example

A minimal TypeScript example that uses the RARE SDK client export:

import { createRareClient } from "@rareprotocol/rare-cli/client";

It demonstrates:

  • read operations (search.nfts, search.collections)
  • optional write flow (media.upload -> media.pinMetadata -> mint.mintTo)

Prerequisites

  • Node.js 22+
  • An RPC URL for your target chain
  • A funded wallet private key (use testnet first)

Install

npm install

Configure environment

Create a .env file from the example:

cp .env.example .env

Required for all runs:

  • RPC_URL
  • PRIVATE_KEY
  • CHAIN (optional; defaults to sepolia)

Optional for mint flow:

  • MINT_EXAMPLE=true
  • CONTRACT_ADDRESS
  • IMAGE_PATH
  • RECIPIENT_ADDRESS (optional; defaults to your wallet address)

Run the example

npm run example

What happens by default (read-only)

When MINT_EXAMPLE is not set to true, the script will:

  1. create a viem public + wallet client
  2. create a RARE client via createRareClient
  3. run rare.search.nfts({ query: "portrait", take: 5 })
  4. run rare.search.collections({ ownerAddresses: [yourAddress], take: 5 })

Enable minting (write flow)

Set MINT_EXAMPLE=true and provide the mint env vars, then run:

npm run example

The script will then:

  1. read your local image file
  2. upload media to IPFS with rare.media.upload
  3. pin metadata with rare.media.pinMetadata
  4. mint with rare.mint.mintTo

Security notes

  • Never commit .env or private keys.
  • Use sepolia / base-sepolia before mainnet.
  • Keep wallet permissions and funds minimal for testing.

Project structure

  • src/simple-sdk-example.ts - the runnable SDK example
  • .env.example - environment template
  • assets/ - sample media files

Package

This example uses the published @rareprotocol/rare-cli package version from package.json.

About

Example of integrating the rare-sdk into a typescript project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors