Welcome to the documents for Story Protocol Python SDK. The Python SDK provides the APIs for developers to build applications with Story Protocol. By using the SDK, developers can create the resources like IP assets and perform actions to interact with the resource.
Suppose you already have a node project or created a new node project. First, you need to install story_protocol_python_sdk
in your project. You can use one of the following command to install the package:
Use pip
:
pip install story_protocol_python_sdk web3
Besides the Story Protocol SDK package story_protocol_python_sdk
, we also require the package web3
(https://pypi.org/project/web3/) to access the DeFi wallet accounts.
Next we can initiate the SDK Client by first setting up our wallet and then the client itself.
The SDK supports using web3
for initiating SDK client. Create a Python file and write the following code to initiate the client with a private key:
:information-source: Make sure to have WALLET_PRIVATE_KEY set up in your .env file.
import os
from dotenv import load_dotenv
from web3 import Web3
load_dotenv()
private_key = os.getenv('WALLET_PRIVATE_KEY')
rpc_url = os.getenv('RPC_PROVIDER_URL')
# Initialize Web3
web3 = Web3(Web3.HTTPProvider(rpc_url))
# Set up the account with the private key
account = web3.eth.account.from_key(private_key)
The preceding code created the account
object for creating the SDK client.
To set up the SDK client, import StoryClient
from story_protocol_python_sdk
. Write the following code, utilizing the account
we created previously.
:information-source: Make sure to have RPC_PROVIDER_URL for your desired chain set up in your .env file. We recommend using the Sepolia network with
RPC_PROVIDER_URL=https://rpc.ankr.com/eth_sepolia
.
from story_protocol_python_sdk import StoryClient
# Create StoryClient instance
sepolia_chain_id = 11155111
story_client = StoryClient(web3, account, sepolia_chain_id)
Package | Description |
---|---|
story_protocol_python_sdk | A Python SDK for interacting with the Story Protocol. |
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Details see: CONTRIBUTING
Please make sure to update tests as appropriate.