Skip to main content

ThirdwebSDK.fromPrivateKey

Instantiate the ThirdwebSDK in read-write mode using a wallets private key.

All transactions made with this instance of the SDK will be signed using the private key.

Usage

Provide the private key and the chain you want to use.

from thirdweb import ThirdwebSDK
from thirdweb.types import SDKOptions
from dotenv.main import load_dotenv
import os

load_dotenv()
secret_key = os.environ['SECRET_KEY']
private_key = os.environ['PRIVATE_KEY']

sdk = ThirdwebSDK.from_private_key(private_key, "mumbai", SDKOptions(secret_key=secret_key))

Configuration

private_key

The private key of the wallet you want to use to initiate transactions with.

Sensitive Value

The private key grants custody over the funds associated with your account.

Losing or leaking your private key will result in the loss of your funds.

from thirdweb import ThirdwebSDK

sdk = ThirdwebSDK.from_private_key(
"private_key", # DANGER: This is a sensitive value that should be stored securely.
"mumbai"
)

chain

The chain you want to use. See configuring chain on the ThirdwebSDK for more information.

from thirdweb import ThirdwebSDK

sdk = ThirdwebSDK.from_private_key(
"private_key", # DANGER: This is a sensitive value that should be stored securely.
"mumbai",
)

options

The optional SDKOptions object to pass as configuration. See configuring sdk options on the ThirdwebSDK page for more information.

from thirdweb import ThirdwebSDK

sdk = ThirdwebSDK.from_private_key(
"private_key",
"mumbai",
SDKOptions(secret_key="...")
)