Mobile Wallet Web3 Browser

The Theta Wallet on mobile (iOS and Android) has support for web3 browsing. Your web app can connect, sign messages, and send transactions using the in-page provider injected by the Theta Wallet browser. Each of these actions will prompt the user to approve the action (sign message, send transaction, etc). The API is very similar to using MetaMask's in-page provider.

Detecting the Theta Wallet Provider

const isThetaWallet = Boolean(window.ethereum && window.ethereum.isThetaWallet);
if(isThetaWallet){
  // User is connected, auto connect them on your site and show them as logged in
}

Get accounts

const accounts = await window.ethereum.request({ method: 'eth_requestAccounts' });

Create provider (ethers.js)

import {providers} from "ethers";

const provider = new providers.Web3Provider(window.ethereum);

Sign a message

const signer = provider.getSigner();
const message = 'YOUR_MESSAGE';
const signature = await signer.signMessage(message);

Sign a transaction

const signer = provider.getSigner();
const CONTRACT_ADDRESS = 'YOUR_CONTRACT_ADDRESS'; // TODO: YOUR ADDRESS
const CONTRACT_ABI = null;// TODO: YOUR ABI
const contract = new ethers.Contract(CONTRACT_ADDRESS, CONTRACT_ABI, signer);
const result = await contract.someFunctionInYourContract();// TODO: correct the function and add any args