All Projects → nftlabs → nftlabs-sdk-python

nftlabs / nftlabs-sdk-python

Licence: Apache-2.0 license
Best in class web3 SDK for Python 3.7+

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to nftlabs-sdk-python

LunDAO
LunDAO 是一個鼓勵撰寫與 Ethereum 社群相關的中深度的中文文章,透過一個短期的實驗專案嘗試 DAO 可以如何進行社群治理以及回饋社群貢獻。
Stars: ✭ 50 (-26.47%)
Mutual labels:  web3
hopr-core
Main repository of HOPR - this is all you need to run a node on the HOPR network!
Stars: ✭ 14 (-79.41%)
Mutual labels:  web3
openmev-sdk
@openmev/sdk
Stars: ✭ 19 (-72.06%)
Mutual labels:  web3
safe-core-sdk
Software developer tools that facilitate the interaction with the Safe contracts and services.
Stars: ✭ 93 (+36.76%)
Mutual labels:  web3
RSS3-SDK-for-JavaScript
⚠️ DEPRECATED
Stars: ✭ 49 (-27.94%)
Mutual labels:  web3
Enterprise-Web3.0
Enterprise™ for the Web3.0™
Stars: ✭ 32 (-52.94%)
Mutual labels:  web3
connect-metamask-react-dapp
Build a simple React / Web3 Dapp that replicates a small portion of the Uniswap v2 interface
Stars: ✭ 204 (+200%)
Mutual labels:  web3
use-contractkit
Connect your react dApp to Celo
Stars: ✭ 49 (-27.94%)
Mutual labels:  web3
web3jdemo
功能强大的web3j以太坊用例,支持批量生成钱包,批量不同账户转账,查询余额等,监控,定时任务,交易mint等方法,持续更新中... ...
Stars: ✭ 262 (+285.29%)
Mutual labels:  web3
Web3-Name-Service
A compatible and inclusive name service for the web3 world, supporting RNS and ENS and more
Stars: ✭ 31 (-54.41%)
Mutual labels:  web3
eth-chains
Helper module for getting Ethereum chains info from chainlist.org.
Stars: ✭ 39 (-42.65%)
Mutual labels:  web3
Mida
The open-source and cross-platform trading framework
Stars: ✭ 263 (+286.76%)
Mutual labels:  web3
ens.py
Ethereum Name Service, made easy in Python
Stars: ✭ 36 (-47.06%)
Mutual labels:  web3
web3-mock
🤡 JavaScript library to mock web3 responses either by emulating web3 wallets or web3 RPC requests.
Stars: ✭ 54 (-20.59%)
Mutual labels:  web3
colonyDapp
Colony dApp client
Stars: ✭ 52 (-23.53%)
Mutual labels:  web3
dtube
Decentralized video sharing & social media platform on Ethereum blockchain.
Stars: ✭ 70 (+2.94%)
Mutual labels:  web3
gochain
The official GoChain client.
Stars: ✭ 138 (+102.94%)
Mutual labels:  web3
vue-web3
🐙 Web3 blockchain bindings for Vue.js (inspired by Vuefire and Drizzle)
Stars: ✭ 63 (-7.35%)
Mutual labels:  web3
eth-decoder
Simple library to decode ethereum transaction and logs
Stars: ✭ 32 (-52.94%)
Mutual labels:  web3
learn-web3-dapp
This Next.js app is designed to be used with the Figment Learn Pathways, to help developers learn about various blockchain protocols such as Solana, NEAR, Secret, Polygon and Polkadot!
Stars: ✭ 1,084 (+1494.12%)
Mutual labels:  web3



thirdweb Python SDK

pypi version Build Status Join our Discord!

Best in class Web3 SDK for Python 3.7+


Installation

pip install thirdweb-sdk

Getting Started

To start using this SDK, you just need to pass in a provider configuration.

Instantiating the SDK

Once you have all the necessary dependencies, you can follow the following setup steps to get started with the SDK read-only functions:

from thirdweb import ThirdwebSDK

# You can create a new instance of the SDK to use by just passing in a network name
sdk = ThirdwebSDK("mumbai")

The SDK supports the mainnet, rinkeby, goerli, polygon, mumbai, fantom, and avalanche networks.

Alternatively, if you want to use your own custom RPC URL, you can pass in the RPC URL directly as follows:

from thirdweb import ThirdwebSDK

# Set your RPC_URL
RPC_URL = "https://rpc-mainnet.matic.network"

# And now you can instantiate the SDK with it
sdk = ThirdwebSDK(RPC_URL)

Working With Contracts

Once you instantiate the SDK, you can use it to access your thirdweb contracts. You can use the SDK's contract getter functions like get_token, get_edition, get_nft_collection, and get_marketplace to get the respective SDK contract instances. To use an NFT Collection contract for example, you can do the following.

# Add your NFT Collection contract address here
NFT_COLLECTION_ADDRESS = "0x.."

# And you can instantiate your contract with just one line
nft_collection = sdk.get_nft_collection(NFT_COLLECTION_ADDRESS)

# Now you can use any of the read-only SDK contract functions
nfts = nft_collection.get_all()
print(nfts)

Signing Transactions

⚠️ Never commit private keys to file tracking history, or your account could be compromised.

Meanwhile, if you want to use write functions as well and connect a signer, you can use the following setup:

from thirdweb import ThirdwebSDK
from thirdweb.types.nft import NFTMetadataInput

# Learn more about securely accessing your private key: https://portal.thirdweb.com/web3-sdk/set-up-the-sdk/securing-your-private-key
PRIVATE_KEY = "<your-private-key-here>",

# Now you can create a new instance of the SDK with your private key
sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, "mumbai")

# Instantiate a new NFT Collection contract as described above.
NFT_COLLECTION_ADDRESS = "0x.."
nft_collection = sdk.get_nft_collection(NFT_COLLECTION_ADDRESS)

# Now you can use any of the SDK contract functions including write functions
nft_collection.mint(NFTMetadataInput.from_json({ "name": "Cool NFT", "description": "Minted with the Python SDK!" }))

Development Environment

In this section, we'll go over the steps to get started with running the Python SDK repository locally and contributing to the code. If you aren't interested in contributing to the thirdweb Python SDK, you can ignore this section.

Poetry Environment Setup

If you want to work with this repository, make sure to setup Poetry, you're virtual environment, and the code styling tools.

Assuming you've installed and setup poetry, you can setup this repository with:

$ poetry shell
$ poetry install
$ poetry run yarn global add ganache
$ poetry run yarn add hardhat

Alternatively, if your system can run .sh files, you can set everything up by running the following bash script:

$ bash scripts/env/setup.sh

Running Tests

Before running tests, make sure you've already run poetry shell and are in the poetry virutal environment with all dependencies installed.

Once you have checked that this you have all the dependencies, you can run the following:

$ poetry run brownie test --network hardhat

To properly setup testing, you'll also need to add your private key to the .env file as follows (do NOT use a private key of one of your actual wallets):

PRIVATE_KEY=...

Code Style Setup

Make sure you have mypy, pylint, and black installed (all included in the dev dependencies with poetry install.

If you're working in VSCode, there a few steps to get everything working with the poetry .venv:

  1. To setup poetry virtual environment inside your VSCode so it gets recognized as part of your project (import for linters), you can take the following steps from this stack overflow answer. You need to run poetry config virtualenvs.in-project true and then make sure you delete/create a new poetry env.
  2. In .vscode/settings.json, you should have the following:
{
  "python.linting.mypyEnabled": true,
  "python.linting.enabled": true,
  "python.linting.pylintEnabled": false
}
  1. Make sure to set your VSCode Python: Interpreter setting to the Python version inside your poetry virtual environment.

Generate Python ABI Wrappers

Use the abi-gen package to create the Python ABIs. You can install it with the following command:

$ npm install -g @0x/abi-gen

Assuming you have the thirdweb contract ABIs in this directory at /abi, you can run the following command to generate the necessary ABIs.

$ make abi
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].