Skip to main content

Official Thirdweb sdk

Project description

NFTLabs Python SDK

PyPi package found here.

Deprecation Notices

1 of 2

The nftlabs-sdk pypi package will be deprecated on November 30th, 2021

Please make sure you install the new thirdweb-sdk package found here

In your code, update all imports to use the thirdweb package and switch to using the ThirdwebSdk package (instead of the NftlabsSdk package)


2 of 2

The collection module has been renamed to bundle and will be deprecated on November 30th, 2021

All references to collection module and its associated classes should be updated to bundle and its newely created classes.

You can find the detailed documentation for the bundle module here

Docs

https://docs.nftlabs.co

API Reference

https://python-docs.nftlabs.co/

Installing the SDK

$ pip install thirdweb-sdk

Package Structure

nftlabs
├── abi       // contains autogenerated ABI contract wrappers 
├── errors    // commonly thrown errors
├── modules   // NFT, Currency, Marketplace, Pack, Bundle, etc modules
├── options   // Options classes used throughout the SDK
├── sdk.py    // NftlabsSdk class, wrapper for the entire package
├── storage   // Distributed file storage helper classes
└── types     // Types consumed by some of the methods exposed in the modules

Calling the modules

You can call the NFTLabs modules by instantiating an SDK object and fetching the module with your contract address like this:

import os
from nftlabs import NftlabsSdk, SdkOptions

sdk = NftlabsSdk(SdkOptions(), "https://rpc-mumbai.maticvigil.com") # polygon testnet as an example

# Assumes your private key is assigned to the `PKEY` environment variable
sdk.set_private_key(os.getenv("PKEY"))

# Put your NFT contract address here if you want to mint your own NFTs!
nft_module = sdk.get_nft_module("0xbDfF8fb43688fB4D2184DF8029A7238ac1413A24")
print(nft_module.total_supply())

Development

Generating ABI wrappers

The abi package contains autogenerated code compiled by the 0xchain abi-gen tool found here.

Our protocols are developer at this repo.

Install the abi-gen cli tool and use it to compile abi wrappers like this:

$ # assumes you have the nftlabs-protocols repo cloned in the parent directory
$ abi-gen --language Python -o nftlabs/abi --abis ../nftlabs-protocols/abi/NFT.json

Anytime there are ABI contract changes, you should regenerate the abi wrappers.

Writing Documentation

This package uses PyDoctor to auto-generate docs. Each method, class and variable should have a detailed description of what it is meant for as a comment enclosed in triple quoation marks (""" """) just below the line they are defined.

Example:

Do:

def my_method(self, arg1, arg2):
    """
    This part goes into the documentation.
    """
    return arg1 + arg2

Don't:

"""
This part will not go into the documentation.
"""

def my_method(self, arg1, arg2):
    return arg1 + arg2

Addtionally, each module should also have a docstring at the top of the file. This will be used as a breif descroption of the module on the homepage of the documentation.

Example:

1 """Interact with the NFT module of the app""" # docstring
2 # Module code starts from here
3 # ...

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thirdweb-sdk-0.4.0.tar.gz (75.6 kB view details)

Uploaded Source

Built Distribution

thirdweb_sdk-0.4.0-py3-none-any.whl (88.8 kB view details)

Uploaded Python 3

File details

Details for the file thirdweb-sdk-0.4.0.tar.gz.

File metadata

  • Download URL: thirdweb-sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 75.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for thirdweb-sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b2328c663fd4ad24e1c1200eaa0a1a0a1f9260242c2b1de6858e2c6208c14920
MD5 a0838e132dcc055512c7dbd7855f1eaa
BLAKE2b-256 8e8ba6106154264d1d0e51b44a6e96f3747cbf4da6e7f236db8f4bb3f32026ce

See more details on using hashes here.

File details

Details for the file thirdweb_sdk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: thirdweb_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 88.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for thirdweb_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 297f90710ad389ef0ee129d53c10acb9b8f6c5b15d84862a43bb009e92d7837d
MD5 359a2ea81ac692a73df1aa12f32a131c
BLAKE2b-256 4a9f2d0d4e7c895277f966a84149f2cb1efc9b99ed0dd6007892be5458f919a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page