Skip to main content

py-algorand-nft-sdk

Introduction

This SDK builds upon the py-algo-sdk NFT minting and updating capabilities, making it a lot easier for developers to create and update NFTs on testnet, betanet and mainnet using the different ARC standards.

The developer simply needs to call the appropriate function to either mint or update an NFT, providing the necessary arguments including the metadata url in accordance with the ARC standard they intend to use.

The ARC standards for NFTs include:

  • ARC3

    • https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0003.md
    • NFT metadata focused standard.
    • The url field points to the NFT metadata. The metadata supports a schema which can have associated integrity and mimetype fields.
    • Suitable for immutable NFTs with large metadata files (>1KB size of JSON) and multiple off-chain data references.
  • ARC19

    • https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md
    • NFT metadata focused standard.
    • Enforces off-chain IPFS metadata by using the url field as a template populated by the reserve address field which holds the IPFS CID. Easy to update since the reserve address value can be replaced with a single transaction, which in turn changes the metadata. The reserve address is only irrelevant (and thus can be used in this way) for pure NFTs (1 of 1).
    • Suitable for mutable NFTs intended to transition into immutable NFTs, with complete metadata (+mediafile) changes.
  • ARC69

    • https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0069.md
    • NFT mediafile focused standard.
    • The url field points to the NFT digital asset file. The ASA metadata is stored on-chain and represented by the note field of the latest valid assetconfig transaction. Since the note field is limited to 1KB the metadata JSON is also restricted to this size. This design means fetching the metadata is complex and requires access to an archive node, but also allows metadata to be updated with a single transaction and simple access to the mediafile url.
    • Suitable for mutable NFTs where the mediafile is locked, easily accessed, but the compact metadata associated with it changes over time.

Getting Started

Prerequisites

At least Python 3.10

Install

#create a virtual environment
python3 -m venv venv

#activate virtual environment
source venv/bin/activate

#update pip
pip install pip upgrade

#install py-algo-nft-sdk
pip install py-algo-nft-sdk

#install py-algo-sdk
pip install -r requirements.txt

Usage

To use the SDK in your python script you simply need to follow the steps below.

Step 1

Import SDK

'''
import the file coresponding to the network that you intend to connect to and alias it.
Testnet: testnet
Betanet: betanet
Mainnet: mainnet
'''
from py_sdk import testnet as nft_sdk

Step 2

Call the function to mint an NFT

create_nft(name, symbol, metadata_url, address, reserve=False, freeze="", clawback="")

Descripton: This function mints a new NFT.

Arguments:

Required :-

  • name: This should be passed as a string and denotes the name of the NFT.
  • symbol: This should be no more than 8 chararacters and passed as a string. It denotes symbol that would be associated with the NFT.
  • metadata_url: This should be passed as a string and should be a URL pointing to a file where the NFT metadata such as an image is stored. If you wish for this NFT to be mutable, then the metadata_url passed must be in accordance with ARC-19 standards.

Optional :- -address: This is an argument of type string and denotes the receiving address of the NFT(i.e) where the NFT would be stored after creation. If no Address is passed, then an address would be generated for the user and information about this address such as the secrete key, the public key and the mnemonic seed phrase would be printed out to the CLI. These must be copied and stored in a secure manner and later import the wallet to GUI such as [MyAlgo wallet] (https://wallet.myalgo.com/) or [Pera Algo wallet] (https://perawallet.app/)

  • freeze: This is an argument of type string. It denotes a wallet that can sign a transaction to freeze the asset. It usually does not apply to NFTs.
  • clawback: This is an argument of type string. It denotes a wallet that can reclaim an asset.

Side Effects: -The function prints out the metadata hash, transaction ID, transaction information and the asset ID to the CLI.

Return: -The function returns the NFT ID (success) or False (failure)

Example: In this example, we create an NFT that can be updated (ARC-19 standard), but with no clawback or freeze address.

nft_sdk.create_nft("exampleNFT", "EX", "https://bit.ly/3WlA41Y#i", True)

Step 3

Fund wallet and Opt-in to asset

-The User or receiver of the NFT must opt-in to the NFT in their wallet by adding the asset ID generated in the previous step to their wallet. -The user must also have few algos in their wallet. You can get algos from the [testnet dispenser] (https://testnet.algoexplorer.io/dispenser) .

You can also use the utility function verify_opt_in() to ensure that the receiver address has opted in to the asset before moving on to the next step.

verify_opt_in(address, asset_id)

Description: checks if an adderess has opted-in to an asset.

Arguments:

Required:- -address: This is an argument of type string. It denotes the wallet to be checked for an opt-in for a particular asset. -asset_id: This is passed an an integer. It denotes the asset ID of the asset to be checked.

Side Effects: None

Return: -True (if the wallet has opted in) else False.

Example:

nft_sdk.verify_opt_in("BKULWP4WWNEFJRAUEZJD4RCWQ6G4XVH24MZINYOHB76SF2MTMFEOM5CABY", 156938060)

You can also use the utility function create_account() to generate a new account create_account()

Description: Creates a new account.

Arguments: Takes no arguments.

Side Effects: -Prints the public key (wallet address), private key and mnemonic seed phrase to the CLI.

Return: -The public key / wallet address.

Example: '''{python} nft_sdk.create_account() ''' This function prints out the account information which you can then copy from the CLI and store in a safe place and later import the wallet to GUI such as [MyAlgo wallet] (https://wallet.myalgo.com/) or [Pera Algo wallet] (https://perawallet.app/)

Optional Step

This step is only required when a user wants to update a mutable NFT. Remember that an NFT is only mutable if the metadata_url passed while creating the NFT was created and passed as specified by the ARC-19 standard.

update_nft(asset_id, metadata_url, clawback="", freeze="")

Descripton: This function updates an NFT.

Arguments:

Required :-

  • metadat_url: This should be passed as a string and should be a URL pointing to a file where the NFT metadata stored. The URL must be in accordance with ARC-19 standards and must be stored on IPFS

Optional :-

  • freeze: This is an argument of type string. It denotes a wallet that can sign a transaction to freeze the asset. It usually does not apply to NFTs.
  • clawback: This is an argument of type string. It denotes a wallet that can reclaim an asset.

Side Effects: -The function prints out the metadata hash, transaction ID, transaction information and the asset ID to the CLI.

Return: -The function returns the NFT ID (success) or False (failure)

Example:

nft_sdk.update_nft(156938060, ipfs://.......)

Deployment

Authors

Owolabi Adeyemi Emmanuel Agbavwe

Acknowledgements

Barnji

Nullun

Nick Stanford

Joe Polony

JP Miller

The ALgorand foundation and the awesome Green House Hacks Team

Metadata

Release files for py-algorand-nft-sdk 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-algorand-nft-sdk 0.0.2
File Size Uploaded
py_algorand_nft_sdk-0.0.2.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-algorand-nft-sdk 0.0.2
File Interpreter ABI Platform
py_algorand_nft_sdk-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 18.7 kB

Release files / py_algorand_nft_sdk-0.0.2.tar.gz

Download URL py_algorand_nft_sdk-0.0.2.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d0f709260aa5671a7c8219f57a855f8123b176a8ceb1ae232e8ee9d931972b0b
BLAKE2b-256 checksum
How to use checksums
24e3995f68c9755d183622d5e14e5f36969be6bc5324540c5c04ac5e5824a1e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / py_algorand_nft_sdk-0.0.2-py3-none-any.whl

Download URL py_algorand_nft_sdk-0.0.2-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33f1046415d9da6cfa3d2ac9984204a687b630bcd3c17004a0a85b09ac191e3c
BLAKE2b-256 checksum
How to use checksums
6a2a87e4e78c1ef258b1adda314e547be208e399506114a7d7959222571de967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page