Skip to main content

ThirdwebSDK.fromPrivateKey() method

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Get an instance of the thirdweb SDK based on a private key.

Example

const sdk = ThirdwebSDK.fromPrivateKey("SecretPrivateKey", "mainnet");

Signature:

static fromPrivateKey(privateKey: string, network: ChainOrRpc, options?: SDKOptions, storage?: ThirdwebStorage): ThirdwebSDK;

Parameters

ParameterTypeDescription
privateKeystringthe private key - **DO NOT EXPOSE THIS TO THE PUBLIC**
networkChainOrRpcthe network (chain) to connect to (e.g. "mainnet", "rinkeby", "polygon", "mumbai"...) or a fully formed RPC url
optionsSDKOptions(Optional) the SDK options to use
storageThirdwebStorage(Optional) optional storage implementation to use

Returns:

ThirdwebSDK

an instance of the SDK

Remarks

This should only be used for backend services or scripts, with the private key stored in a secure way. **NEVER** expose your private key to the public in any way.