TokenBoundSmartWallet
function constructor(
SmartWallet.addAdmin
Add another admin to the smart wallet.
function addAdmin( adminAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.addListener
function addListener( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
SmartWallet.autoConnect
auto-connect the wallet if possible
function autoConnect(): Promise<string>;
SmartWallet.connect
Connect 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.createSessionKey
Create 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.deploy
Manually 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.deployIfNeeded
Manually 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.emit
Calls each of the listeners registered for a given event.
function emit( event: T,): boolean;
SmartWallet.estimate
Estimate 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.estimateBatch
Estimate 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.estimateBatchRaw
Estimate 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.estimateRaw
Estimate 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.eventNames
Return an array listing the events for which the emitter has registered listeners.
SmartWallet.execute
Execute 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.executeBatch
Execute 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.executeBatchRaw
Execute multiple raw transactions in a single batch and wait for confirmations
function executeBatchRaw( transactions: Array<Deferrable<TransactionRequest>>,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.executeRaw
Execute a single raw transaction and wait for confirmations
function executeRaw( transaction: Deferrable<TransactionRequest>,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.getAccountContract
Get the underlying account contract of the smart wallet.
The account contract of the smart wallet.
SmartWallet.getAllActiveSigners
Get all the admins and session keys active on the smart wallet.
SmartWallet.getBalance
Returns 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.getFactoryContract
Get the underlying account factory contract of the smart wallet.
The account factory contract.
SmartWallet.getSigner
Get ethers Signer object of the connected wallet
function getSigner(): Promise<Signer>;
SmartWallet.hasPermissionToExecute
Check 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.listenerCount
Return the number of listeners listening to a given event.
SmartWallet.listeners
Return the listeners registered for a given event.
function listeners( event: T,): Array< ( ) => void>;
let returnType: Array< ( ) => void>;
SmartWallet.off
function off( event: T, fn?: ( ) => void, context?: any, once?: boolean,): this;
let fn: () => void;
SmartWallet.on
Add a listener for a given event.
function on( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
SmartWallet.once
Add a one-time listener for a given event.
function once( event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
SmartWallet.removeAdmin
Remove an admin from the smart wallet.
function removeAdmin( adminAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.removeListener
Remove the listeners of a given event.
function removeListener( event: T, fn?: ( ) => void, context?: any, once?: boolean,): this;
let fn: () => void;
SmartWallet.revokeSessionKey
Revoke 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.send
Send a single transaction without waiting for confirmations
function send( Omit<TransactionResultWithMetadata<unknown>, "data"> >,): Promise<TransactionResponse>;
the transaction to send
Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.sendBatch
Send 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.sendBatchRaw
Send multiple raw transaction in a batch without waiting for confirmations
function sendBatchRaw( transactions: Array<Deferrable<TransactionRequest>>,): Promise<TransactionResponse>;
SmartWallet.sendRaw
Send a single raw transaction without waiting for confirmations
function sendRaw( transaction: Deferrable<TransactionRequest>,): Promise<TransactionResponse>;
SmartWallet.transfer
Transfers some amount of tokens to the specified address
function transfer( to: string, amount: string | number, currencyAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
SmartWallet.updateChains
Update 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>;