Skip to content
Terra WalletDevelopers

Early access. The Terra API and SDKs may change before launch, and the SDK packages are not published yet.

View as Markdown

Terra Connect

Early access

wagmi

wagmi discovers EIP-6963 wallets by default, so a wagmi app lists Terra Wallet with no extra code when the extension is installed. Add the WalletConnect connector for phones and for users without the extension.

Setup (works today)#

TypeScript

// npm install wagmi viem @tanstack/react-query @walletconnect/ethereum-providerimport { createConfig, http } from "wagmi";import { base, mainnet, polygon } from "wagmi/chains";import { walletConnect } from "wagmi/connectors"; export const config = createConfig({  chains: [mainnet, base, polygon],  // EIP-6963 discovery (multiInjectedProviderDiscovery) is on by default.  connectors: [walletConnect({ projectId: "<your-walletconnect-project-id>" })],  transports: {    [mainnet.id]: http(),    [base.id]: http(),    [polygon.id]: http(),  },});

A "Connect Terra Wallet" button#

TSX

// wagmi 3: useConnect returns a mutation; start it with connect.mutate({ connector }).import { useConnect, useConnectors } from "wagmi"; export function ConnectTerraWallet() {  const connectors = useConnectors();  const connect = useConnect();   // EIP-6963 connectors take their id and name from the wallet's announcement.  const terra = connectors.find((c) => c.id === "com.terrawallet.app" || c.name === "Terra Wallet");  const connector = terra ?? connectors.find((c) => c.id === "walletConnect");  if (!connector) return null;   return (    <button disabled={connect.isPending} onClick={() => connect.mutate({ connector })}>      {terra ? "Connect Terra Wallet" : "Connect with WalletConnect"}    </button>  );}

Wrap your app in wagmi's WagmiProvider and a TanStack Query QueryClientProvider as the wagmi docs describe.

The planned Terra connector#

The planned react package will include a wagmi/viem connector and a Solana wallet-adapter, with Terra Wallet's deep link handoff on phones. It is not published:

Shell

# npm install @terrawallet/react (not published yet; name may change)

Until then, the setup above is the supported way. See SDK: react.

Sources for the wagmi API used here: wagmi's createConfig (multiInjectedProviderDiscovery defaults to true) and walletConnect connector documentation at wagmi.sh.