Skip to content

sagacards/legends-nft

Repository files navigation

Saga Legends NFT Canister

Preview

Collectible Major Arcana for Early Saga Adopters.
https://legends.saga.cards.

This canister is a fairly complete NFT solution which generally follows the EXT standard. It may vary from other canisters using the EXT standard for lack of complete standards documentation. No guarantees that it matches your specific NFT use case.

A Legends NFT example: The Fool Mint #1

  • Maintains ownership ledger
  • Manages assets in this canister
  • Integrates CAP for provinance and transaction history
  • Provides public sale functionality, with some support scripts
  • Interfaces with the entrepot marketplace
  • Works with plug, stoic and earth wallets
  • Provides functionality to drain and restore stable state
  • Flexible HTTP Interface
  • Provide payouts from primary and secondary sales based on a per-canister configurable distribution map
  • Integrate covercode.ooo

This single repository powers all of the legends NFTs, where each release is individually deployed to the IC (i.e. the fool is one canister, the magician is another, and so on.) This repo contains the source code of these canisters, as well as some scripts to help manage the deployment and configuration of the fleet of canisters that make up the legends series of NFTs.

Development & Deployment

There are two test canisters: charlie and foxtrot. Charlie on local network will be the default for most commands. You may wish to setup a local instance of CAP.

dfx start --clean --background
zsh/deploy.zsh
dfx canister call charlie addAdmin "principal \"$(dfx identity get-principal)\""
zsh/configure.zsh

You can specify network as well as which legend you would like to deploy using command line arguments like so:

# zsh/deploy.zsh <CANISTER_NAME:charlie> <NETWORK:local>
zsh/deploy.zsh charlie local

To create a new legend canister, perform the following initial setup:

  • add an entry to dfx.json
  • clone the private art repository into this repo, and place all of the art assets there
  • create a manifest for the art, and a config json for the canister
  • make sure you use the same name string from dfx.json as the name of the config files

Then you can deploy your new canister (this will use the canisters config) followed by uploading all of the assets from your manifest (this will take a while—benchmarked with the fool at ~2hr on mainnet and slightly less on local replica.)

  • Add process pool to upload bash script and multiple upload buffers to canister to enable parallel uploads in order to cut upload times
zsh/deploy.zsh my-new-canister somenet
dfx canister call my-new-canister addAdmin "principal \"$(dfx identity get-principal)\""
zsh/manifest_upload.zsh my-new-canister somenet

Finally, the metadata for each legend needs to be configured:

zsh/configure.zsh my-new-canister somenet
  • Add metadata shuffling
  • Improve metadata solution in general

Once the NFT canister is deployed, it should be submitted to DAB so that it can be discovered by other wallets an dApps.

Uploading Assets

Assets are stored with a basic set of metadata, including tags which provide an easy way to query those assets. The assets themselves are stored as byte buffers using the asset-storage.mo library.

After installing the NFT canister on the IC mainnet or local replica, you can use the upload zshell scripts in this repository to provision that canister with assets. The assets themselves are stored in a private art repository.

If you are creating a new set of art assets for a canister, after you've created all of said assets you will need to generate a new manifest file.

To begin the upload process, run the following command:

# zsh/manifest_upload.zsh <CANISTER> <NETWORK>
zsh/manifest_upload.zsh charlie ic

You may run into errors when using the upload script, if your shell cannot handle the chunk sizes. In that case, you should tweak the threshold parameter in zsh/upload.zsh.

Validating Assets

Run the following to ensure that all of the tokens have their assets.

zsh/manifest_validate.zsh

Generating a Manifest

Many of the common assets you can simply copy from another manifest file. For batches of assets, you can use zsh/manifest_generate.zsh to help generate your manifest rows.

  • node.js uploads and utility scripts (that's enough of zsh)

Legend Metadata

Each token exponses a JSON HTTP endpoint that describes all of the metadata required to display that token in an arbitrary rendering context. Example: /0.json.

HTTP Interface

View                    Path
Interactive (primary)   https://nges7-giaaa-aaaaj-qaiya-cai.raw.ic0.app/0
Static                  https://nges7-giaaa-aaaaj-qaiya-cai.raw.ic0.app/0.webp
Animated                https://nges7-giaaa-aaaaj-qaiya-cai.raw.ic0.app/0.webm
Metadata (developers)   https://nges7-giaaa-aaaaj-qaiya-cai.raw.ic0.app/0.json

A number of other paths are also supported to interoperate with various wallets and dApps.