Skip to main content

trustWallet

A wallet configurator for trust Wallet which allows integrating the wallet with React.

trust Wallet is an extension of our WalletConnect wallet which supports WCV2.

import { trustWallet } from "@thirdweb-dev/react";

const trustWalletConfig = trustWallet(options);

options

projectId (recommended)

Your project's unique identifier that can be obtained at cloud.walletconnect.com.

Defaults to a common thirdweb projectId. We recommend getting your own projectId at cloud.walletconnect.com when launching your project.

import { trustWallet } from "@thirdweb-dev/react";

trustWallet({
projectId: "your-wallet-connect-project-id",
});

Usage with ConnectWallet

To allow users to connect to this wallet using the ConnectWallet component, you can add it to ThirdwebProvider's supportedWallets prop.

<ThirdwebProvider supportedWallets={[trustWallet()]} clientId="your-client-id">
<YourApp />
</ThirdwebProvider>

Usage with useConnect

you can use the useConnect hook to programmatically connect to the wallet without using the ConnectWallet component.

The wallet also needs to be added in ThirdwebProvider's supportedWallets if you want the wallet to auto-connect on next page load.

const trustWalletConfig = trustWallet();

function App() {
const connect = useConnect();

const handleConnect = async () => {
await connect(trustWalletConfig, connectOptions);
};

return <div> ... </div>;
}

connectOptions

{ chainId?: string } | undefined
chainId (optional)

If chainId is provided, wallet will be connected and immediately switch to network with given chainId.

Chain object corresponding to this chainId from @thirdweb-dev/chains package must be specified in ThirdwebProvider's supportedChains prop as shown below

import { Polygon } from "@thirdweb-dev/chains";
import { ThirdwebProvider } from "@thirdweb-dev/react";

export function YourApp() {
return (
<ThirdwebProvider supportedChains={[Polygon]} clientId="your-client-id">
<App />
</ThirdwebProvider>
);
}