PrivateKeyWallet
Wallet interface to connect using a Private Key
import { PrivateKeyWallet } from "@thirdweb-dev/wallets"; // can be any ethers.js signerconst privateKey = process.env.PRIVATE_KEY;const wallet = new PrivateKeyWallet(privateKey);
Create instance of PrivateKeyWallet
function constructor( privateKey: string, secretKey?: string,
The chain or rpc url to connect to when querying the blockchain directly through this wallet.
Provide secretKey to use the thirdweb RPCs for given chain
You can create a secret key from thirdweb dashboard .
let secretKey: string;
Get the ethers.js signer object used by the wallet
function getSigner(): Promise<Signer>;
AbstractWallet.addListenerfunction addListener( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
AbstractWallet.emitCalls each of the listeners registered for a given event.
function emit( event: T,): boolean;
AbstractWallet.eventNamesReturn an array listing the events for which the emitter has registered listeners.
AbstractWallet.getBalanceReturns the balance of the connected wallet for the specified token address. If no token address is specified, it returns the balance of the native token
function getBalance( tokenAddress: string,): Promise<{ decimals: number; displayValue: string; name: string; symbol: string; value: BigNumber;}>;
AbstractWallet.listenerCountReturn the number of listeners listening to a given event.
AbstractWallet.listenersReturn the listeners registered for a given event.
function listeners( event: T,): Array< ( ) => void>;
let returnType: Array< ( ) => void>;
AbstractWallet.offfunction off( event: T, fn?: ( ) => void, context?: any, once?: boolean,): this;
let fn: () => void;
AbstractWallet.onAdd a listener for a given event.
function on( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
AbstractWallet.onceAdd a one-time listener for a given event.
function once( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
AbstractWallet.removeListenerRemove the listeners of a given event.
function removeListener( event: T, fn?: ( ) => void, context?: any, once?: boolean,): this;
let fn: () => void;
AbstractWallet.transferTransfers some amount of tokens to the specified address
function transfer( to: string, amount: string | number, currencyAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
AbstractWallet.verifySignature Verify the signature of a message. It returns true if the signature is valid, false otherwise
function verifySignature( message: string, signature: string, address: string, _chainId?: number,): Promise<boolean>;