NFTLabs Python SDK
PyPi package found here.
Deprecation Notices
1 of 2
The
nftlabs-sdkpypi package will be deprecated on November 30th, 2021Please make sure you install the new
thirdweb-sdkpackage found hereIn your code, update all imports to use the
thirdwebpackage and switch to using theThirdwebSdkpackage (instead of theNftlabsSdkpackage)
2 of 2
The
collectionmodule has been renamed tobundleand will be deprecated on November 30th, 2021All references to
collectionmodule and its associated classes should be updated tobundleand its newely created classes.You can find the detailed documentation for the
bundlemodule here
Docs
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 # ...
Metadata
Release files for nftlabs-sdk 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nftlabs-sdk-0.4.0.tar.gz | 73.8 kB | Without provenance | Details for nftlabs-sdk-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nftlabs_sdk-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for nftlabs_sdk-0.4.0-py3-none-any.whl |
Total release size: 162.6 kB
Release files / nftlabs-sdk-0.4.0.tar.gz
| Download URL | nftlabs-sdk-0.4.0.tar.gz |
|---|---|
| Size | 73.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0f102e233ae0f2bf0227c4a2a22e11a6e74497f6922a9c68455f6ae306c639a
|
|
BLAKE2b-256 checksum How to use checksums |
ebc468af92224fbddee3d24b5174a73250f07936c2a9bb398697219b11d6f9aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / nftlabs_sdk-0.4.0-py3-none-any.whl
| Download URL | nftlabs_sdk-0.4.0-py3-none-any.whl |
|---|---|
| Size | 88.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c691dd7fe36710e2dd4cab3bc42ea7c2bf6457995f67895d6660225fbad088e
|
|
BLAKE2b-256 checksum How to use checksums |
c6f9cc3563331a912a3fcde98f69ee140cf59c43b0b606fa8f36226ba9ddfd6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for nftlabs-sdk 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.