TokenBoundSmartWallet
function constructor(
Returns the Wallet Connector used by the wallet
function getConnector(): Promise<TokenBoundSmartWalletConnector>;
SmartWallet.addAdminAdd another admin to the smart wallet.
function addAdmin( adminAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.addListenerfunction addListener( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
SmartWallet.autoConnectauto-connect the wallet if possible
function autoConnect(): Promise<string>;
SmartWallet.connectConnect the SmartWallet with given personalWallet
function connect(): Promise<string>;
The connectOptions object includes the following properties:
personalWallet
The instance of a personal wallet that can sign transactions on the Smart Wallet.
Must be of type EVMWallet instance such as CoinbaseWallet or MetamaskWallet .
SmartWallet.createSessionKeyCreate and add a session key to the Smart Wallet with specific permissions.
// Then you can add session keys with permissionsawait wallet.createSessionKey( "0x...", // the session key address { approvedCallTargets: ["0x..."], // the addresses of contracts that the session key can call nativeTokenLimitPerTransaction: 0.1, // the maximum amount of native token (in ETH) that the session key can spend per transaction startDate: new Date(), // the date when the session key becomes active expirationDate = new Date(Date.now() + 24 * 60 * 60 * 1000); // the date when the session key expires });
function createSessionKey( keyAddress: string, permissions: { approvedCallTargets: Array<string> | "*"; expirationDate?: number | Date; nativeTokenLimitPerTransaction?: string | number; startDate?: number | Date; },): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
The specific permissions to give to the session key.
Must be of type SignerPermissionsInput from the @thirdweb-dev/sdk package.
{ startDate: Date; expirationDate: Date; nativeTokenLimitPerTransaction: number; approvedCallTargets: string[];}
let permissions: { approvedCallTargets: Array<string> | "*"; expirationDate?: number | Date; nativeTokenLimitPerTransaction?: string | number; startDate?: number | Date;};
SmartWallet.deployManually deploy the smart wallet contract. If already deployed this will throw an error.
Note that this is not necessary as the smart wallet will be deployed automatically on the first transaction the user makes.
const tx = await wallet.deploy();
function deploy(): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.deployIfNeededManually deploy the smart wallet contract. If already deployed this will do nothing. Note that this is not necessary as the smart wallet will be deployed automatically on the first transaction the user makes.
await wallet.deployIfNeeded();
SmartWallet.disconnectDisconnect the wallet
function disconnect(): Promise<void>;
SmartWallet.emitCalls each of the listeners registered for a given event.
function emit( event: T,): boolean;
SmartWallet.estimateEstimate the gas cost of a single transaction
function estimate(): Promise<{ details: { deployCost: BigNumber; deployGasLimit: BigNumber; gasPrice: BigNumber; totalCost: BigNumber; transactionCost: BigNumber; transactionGasLimit: BigNumber; }; ether: string; wei: BigNumber;}>;
SmartWallet.estimateBatchEstimate the gas cost of a batch of transactions
function estimateBatch(): Promise<{ details: { deployCost: BigNumber; deployGasLimit: BigNumber; gasPrice: BigNumber; totalCost: BigNumber; transactionCost: BigNumber; transactionGasLimit: BigNumber; }; ether: string; wei: BigNumber;}>;
SmartWallet.estimateBatchRawEstimate the gas cost of a batch of raw transactions
function estimateBatchRaw( transactions: Array<Deferrable<TransactionRequest>>,): Promise<{ details: { deployCost: BigNumber; deployGasLimit: BigNumber; gasPrice: BigNumber; totalCost: BigNumber; transactionCost: BigNumber; transactionGasLimit: BigNumber; }; ether: string; wei: BigNumber;}>;
SmartWallet.estimateRawEstimate the gas cost of a single raw transaction
function estimateRaw( transactions: Deferrable<TransactionRequest>,): Promise<{ details: { deployCost: BigNumber; deployGasLimit: BigNumber; gasPrice: BigNumber; totalCost: BigNumber; transactionCost: BigNumber; transactionGasLimit: BigNumber; }; ether: string; wei: BigNumber;}>;
SmartWallet.eventNamesReturn an array listing the events for which the emitter has registered listeners.
SmartWallet.executeExecute a single transaction and wait for confirmations
const transaction = prepareTransaction();await wallet.execute(transaction);
function execute( Omit<TransactionResultWithMetadata<unknown>, "data"> >,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
The transaction to execute. Must be of type Transaction from the @thirdweb-dev/sdk package.
Creating these transactions can be done easily using the Transaction Builder from the thirdweb SDK.
Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.executeBatchExecute multiple transactions in a single batch and wait for confirmations, only requiring one signature from the personal wallet.
// Then you can execute multiple transactions at onceconst transactions = [ prepareTransaction1(), prepareTransaction2(), prepareTransaction3(),];await wallet.executeBatch(transactions);
function executeBatch(): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
An array of transactions to execute. Must be of type Transaction[] from the @thirdweb-dev/sdk package.
Creating these transactions can be done easily using the Transaction Builder from the thirdweb SDK.
SmartWallet.executeBatchRawExecute multiple raw transactions in a single batch and wait for confirmations
function executeBatchRaw( transactions: Array<Deferrable<TransactionRequest>>,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.executeRawExecute a single raw transaction and wait for confirmations
function executeRaw( transaction: Deferrable<TransactionRequest>,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.getAccountContractGet the underlying account contract of the smart wallet.
The account contract of the smart wallet.
SmartWallet.getAddressReturns the account address of the connected wallet
function getAddress(): Promise<string>;
SmartWallet.getAllActiveSignersGet all the admins and session keys active on the smart wallet.
SmartWallet.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;}>;
SmartWallet.getChainIdReturns the chain id of the network that the wallet is connected to
function getChainId(): Promise<number>;
SmartWallet.getFactoryContractGet the underlying account factory contract of the smart wallet.
The account factory contract.
SmartWallet.getPersonalWalletGet the personal wallet that is connected to the Smart Wallet.
const personalWallet = wallet.getPersonalWallet();
SmartWallet.getSignerGet ethers Signer object of the connected wallet
function getSigner(): Promise<Signer>;
SmartWallet.hasPermissionToExecuteCheck whether the connected signer can execute a given transaction using the smart wallet.
function hasPermissionToExecute( Omit<TransactionResultWithMetadata<unknown>, "data"> >,): Promise<boolean>;
The transaction to execute using the smart wallet.
Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.isDeployedCheck if the smart wallet contract is deployed
const isDeployed = await wallet.isDeployed();
function isDeployed(): Promise<boolean>;
SmartWallet.listenerCountReturn the number of listeners listening to a given event.
SmartWallet.listenersReturn the listeners registered for a given event.
function listeners( event: T,): Array< ( ) => void>;
let returnType: Array< ( ) => void>;
SmartWallet.offfunction off( event: T, fn?: ( ) => void, context?: any, once?: boolean,): this;
let fn: () => void;
SmartWallet.onAdd a listener for a given event.
function on( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
SmartWallet.onceAdd a one-time listener for a given event.
function once( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
SmartWallet.removeAdminRemove an admin from the smart wallet.
function removeAdmin( adminAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.removeListenerRemove the listeners of a given event.
function removeListener( event: T, fn?: ( ) => void, context?: any, once?: boolean,): this;
let fn: () => void;
SmartWallet.revokeSessionKeyRevoke a session key from the Smart Wallet.
await wallet.revokeSessionKey( "0x...", // the session key address);
function revokeSessionKey( keyAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.sendSend a single transaction without waiting for confirmations
function send( Omit<TransactionResultWithMetadata<unknown>, "data"> >,): Promise<TransactionResponse>;
the transaction to send
Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.sendBatchSend a multiple transaction in a batch without waiting for confirmations
function sendBatch( transactions: Array< >,): Promise<TransactionResponse>;
An array of transactions to send. Must be of type Transaction[] from the @thirdweb-dev/sdk package.
Creating these transactions can be done easily using the Transaction Builder from the thirdweb SDK.
let transactions: Array<>;
SmartWallet.sendBatchRawSend multiple raw transaction in a batch without waiting for confirmations
function sendBatchRaw( transactions: Array<Deferrable<TransactionRequest>>,): Promise<TransactionResponse>;
SmartWallet.sendRawSend a single raw transaction without waiting for confirmations
function sendRaw( transaction: Deferrable<TransactionRequest>,): Promise<TransactionResponse>;
SmartWallet.signMessageSign a message with the connected wallet and return the signature
function signMessage(message: string | Bytes): Promise<string>;
SmartWallet.switchChainSwitch to different Network/Blockchain in the connected wallet
function switchChain(chainId: number): Promise<void>;
SmartWallet.transferTransfers some amount of tokens to the specified address
function transfer( to: string, amount: string | number, currencyAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.updateChainsUpdate the chains supported by the wallet. This is useful if wallet was initialized with some chains and this needs to be updated without re-initializing the wallet
function updateChains(chains: Array<Chain>): Promise<void>;
SmartWallet.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>;
let tbaConnector: TokenBoundSmartWalletConnector;
let tbaOptions: TokenBoundSmartWalletConfig;
let walletId: string;
let prefixed: string | boolean;