ImTokenWallet
The base class for all client-side wallets (web, mobile) in the Wallet SDK. It extends AbstractWallet and adds client side specific logic. A client side wallet delegates the wallet-specific connection logic to a Connector.
This wallet is not meant to be used directly, but instead be extended to build your own wallet
Connect to the wallet using a QR code. You can use this method to display a QR code. The user can scan this QR code using the Trust Wallet mobile app to connect to your dapp.
wallet.connectWithQrCode({ chainId: 1, onQrCodeUri(qrCodeUri) { // render the QR code with `qrCodeUri` }, onConnected(accountAddress) { // update UI to show connected state },});
function connectWithQrCode( options: ConnectWithQrCodeArgs,): Promise<void>;
The options object contains the following properties/method:
chainId (optional)
If provided, wallet will prompt the user to switch to the network with the given chainId
after connecting.
onQrCodeUri
A callback to get the QR code URI to display to the user.
onConnected
A callback that is called when the user has connected their wallet using the QR code.
let options: ConnectWithQrCodeArgs;
AbstractClientWallet.addListener
event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
AbstractClientWallet.autoConnect
auto-connect the wallet if possible
function autoConnect(connectOptions?: { chainId?: number;}): Promise<string>;
AbstractClientWallet.connect
Connect wallet
function connect(connectOptions?: { chainId?: number;}): Promise<string>;
AbstractClientWallet.disconnect
Disconnect the wallet
function disconnect(): Promise<void>;
AbstractClientWallet.emit
Calls each of the listeners registered for a given event.
event: T,): boolean;
AbstractClientWallet.eventNames
Return an array listing the events for which the emitter has registered listeners.
AbstractClientWallet.getAddress
Returns the account address of the connected wallet
function getAddress(): Promise<string>;
AbstractClientWallet.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;}>;
AbstractClientWallet.getChainId
Returns the chain id of the network that the wallet is connected to
function getChainId(): Promise<number>;
AbstractClientWallet.getPersonalWallet
If the wallet uses another "personal wallet" under the hood, return it
This is only useful for wallets like Safe or Smart Wallet uses a "personal wallet" under the hood to sign transactions. This method returns that wallet
AbstractClientWallet.getSigner
Get ethers Signer object of the connected wallet
function getSigner(): Promise<Signer>;
AbstractClientWallet.listenerCount
Return the number of listeners listening to a given event.
AbstractClientWallet.listeners
Return the listeners registered for a given event.
event: T,): Array< ( ) => void>;
let returnType: Array< ( ) => void>;
AbstractClientWallet.off
event: T, fn?: ( ) => void, context?: any, once?: boolean,): this;
let fn: () => void;
AbstractClientWallet.on
Add a listener for a given event.
event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
AbstractClientWallet.once
Add a one-time listener for a given event.
event: T, fn: ( ) => void, context?: any,): this;
let fn: () => void;
AbstractClientWallet.removeListener
Remove the listeners of a given event.
event: T, fn?: ( ) => void, context?: any, once?: boolean,): this;
let fn: () => void;
AbstractClientWallet.signMessage
Sign a message with the connected wallet and return the signature
function signMessage(message: string | Bytes): Promise<string>;
AbstractClientWallet.switchChain
Switch to different Network/Blockchain in the connected wallet
function switchChain(chainId: number): Promise<void>;
AbstractClientWallet.transfer
Transfers some amount of tokens to the specified address
function transfer( to: string, amount: string | number, currencyAddress: string,): Promise<Omit<TransactionResultWithMetadata<unknown>, "data">>;
AbstractClientWallet.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>;
AbstractClientWallet.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 imtokenConnector: ImTokenConnector;
let isInjected: boolean;
let walletConnectConnector: WalletConnectConnector;
let walletId: string;
let id: string;
let meta: { iconURL: string; name: string; urls: { android: string; ios: string };};
type iconURL = string;
type name = string;
type urls = { android: string; ios: string };
let prefixed: string | boolean;
let walletName: "imToken";