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

EIP-6963 and EIP-1193

The Terra Wallet extension injects a standard EIP-1193 provider and announces it through EIP-6963. The Terra Wallet app's dApp browser injects EVM and Solana providers too. This works today with no Terra SDK.

Discover Terra Wallet (EIP-6963)#

EIP-6963 lets several wallets announce themselves without fighting over window.ethereum. Listen for announcements, then ask wallets to announce:

JavaScript

// Works today: find Terra Wallet through EIP-6963.const wallets = new Map();window.addEventListener("eip6963:announceProvider", (event) => {  wallets.set(event.detail.info.uuid, event.detail);});window.dispatchEvent(new Event("eip6963:requestProvider")); export function findTerraWallet() {  return [...wallets.values()].find((w) => w.info.rdns === "com.terrawallet.app") ?? null;}

Each announcement carries info (uuid, name, icon, rdns) and provider (EIP-1193). Terra Wallet's rdns is com.terrawallet.app. Show the wallet's own info.name and info.icon in your wallet picker.

Connect (EIP-1193)#

Ask for accounts from a user action such as a click:

JavaScript

async function connectTerraWallet() {  const terra = findTerraWallet();  if (!terra) throw new Error("Terra Wallet is not installed");  const [account] = await terra.provider.request({ method: "eth_requestAccounts" });  const chainId = await terra.provider.request({ method: "eth_chainId" }); // hex, for example "0x1"  return { provider: terra.provider, account, chainId };}

Listen for changes:

JavaScript

terra.provider.on("accountsChanged", (accounts) => { /* empty array: disconnected */ });terra.provider.on("chainChanged", (chainIdHex) => { /* reload chain-specific state */ });

Sign a message#

Use personal_sign for login messages, ideally in the Sign-In with Ethereum (EIP-4361) format, and eth_signTypedData_v4 for structured data. eth_sign is disabled.

JavaScript

const message = `shop.example.com wants you to sign in with your account:\n${account}\n\nNonce: ${nonce}`;const signature = await terra.provider.request({  method: "personal_sign",  params: [message, account],});// Send { message, signature } to your server and verify it there.

Server-side verification samples (Node and Python) are available from the MCP tool get_code_sample with product: "connect".

Switch chains#

JavaScript

await terra.provider.request({  method: "wallet_switchEthereumChain",  params: [{ chainId: "0x2105" }], // Base (8453)});

Terra Wallet connects dApps on Ethereum, BNB Smart Chain, Polygon, Avalanche, Arbitrum, Optimism, Base and Fantom (chain ids in Supported networks and assets). Handle error code 4902 (unknown chain) and 4001 (the user rejected the request).

Solana#

Terra Wallet registers a Solana Wallet Standard wallet named "Terra Wallet", so Solana dApps that use the Wallet Standard (for example through the Solana wallet-adapter) list it automatically. A legacy window.solana provider is also available.

Errors to handle#

CodeMeaning
4001The user rejected the request
4100The account or method is not authorized yet: connect first
4200The method is not supported (for example eth_sign)
4902The chain is not known to the wallet