Developer Document

Welcome to the WOW Wallet API documentation. This guide will help you integrate WOW Wallet functionality into your web3 applications,
allowing users to interact with your dApp using their WOW Wallet.

Table of Contents

1. [Accessing the Injected Provider](#accessing-the-injected-provider)
2. [Connecting to WOW Wallet](#connecting-to-wow-wallet)
3. [Account Management](#account-management)
       - [Get Selected Account](#get-selected-account)
       - [Listen for Account Changes](#listen-for-account-changes)
4. [Chain Management](#chain-management)
       - [Get Current Chain ID](#get-current-chain-id)
      - [Listen for Chain ID Changes](#listen-for-chain-id-changes)
       - [Request Chain ID Change](#request-chain-id-change)
5. [Sending Transactions](#sending-transactions)
6. [Deep Linking](#deep-linking)

Accessing the Injected Provider

To interact with the WOW Wallet, you first need to access the injected provider. Use the following function to detect and retrieve the WOW Wallet provider:

javascript

				
					function getWOWWalletFromWindow() {
  const isWOWWallet = (ethereum) => {
    return !!ethereum.isWOW;
  };

  const injectedProviderExist =
    typeof window !== "undefined" && typeof window.ethereum !== "undefined";

  if (!injectedProviderExist) {
    return null;
  }

  if (isWOWWallet(window.ethereum)) {
    return window.ethereum;
  }
}

// Usage
const injectedProvider = getWOWWalletFromWindow();
				
			

Connecting to WOW Wallet

To establish a connection with the user's WOW Wallet, use the `eth_requestAccounts` method:

javascript

				
					async function connectToWOWWallet() {
  try {
    const accounts = await injectedProvider.request({
      method: "eth_requestAccounts",
    });
    console.log("Connected account:", accounts[0]);
    return accounts[0];
  } catch (error) {
    if (error.code === 4001) {
      console.error("User denied connection.");
    } else {
      console.error("An error occurred:", error);
    }
    return null;
  }
}
				
			

Account Management
Get Selected Account

To retrieve the currently selected account:

javascript

				
					async function getSelectedAccount() {
  const accounts = await injectedProvider.request({
    method: "eth_accounts",
  });
  return accounts[0] || null;
}
				
			

Listen for Account Changes

To detect when the user changes accounts or disconnects:

javascript

				
					function listenForAccountChanges(callback) {
  injectedProvider.addListener("accountsChanged", (accounts) => {
    if (accounts.length === 0) {
      console.log("User disconnected.");
      callback(null);
    } else {
      const newConnectedAccount = accounts[0];
      console.log("New connected account:", newConnectedAccount);
      callback(newConnectedAccount);
    }
  });
}
				
			

Chain Management
Get Current Chain ID

async function getCurrentChainId() { const chainId = await injectedProvider.request({ method: "eth_chainId" }); return chainId; }

javascript

				
					function listenForAccountChanges(callback) {
  injectedProvider.addListener("accountsChanged", (accounts) => {
    if (accounts.length === 0) {
      console.log("User disconnected.");
      callback(null);
    } else {
      const newConnectedAccount = accounts[0];
      console.log("New connected account:", newConnectedAccount);
      callback(newConnectedAccount);
    }
  });
}
				
			

Listen for Chain ID Changes

To detect when the user changes the network:

javascript

				
					function listenForChainChanges(callback) {
  injectedProvider.addListener("chainChanged", (chainId) => {
    console.log("Chain changed to:", chainId);
    callback(chainId);
  });
}
				
			

Request Chain ID Change

To request a change to a specific network:

javascript

				
					async function requestChainChange(chainId) {
  try {
    await injectedProvider.request({
      method: "wallet_switchEthereumChain",
      params: [{ chainId: chainId }],
    });
    console.log("Successfully switched to chain ID:", chainId);
  } catch (error) {
    if (error.code === 4902) {
      console.log("Chain not added to wallet. Please add it first.");
    } else if (error.code === 4001) {
      console.log("User rejected the request.");
    } else {
      console.error("An error occurred:", error);
    }
  }
}
				
			

Sending Transactions

To send a transaction:

javascript

				
					async function sendTransaction(transactionParameters) {
  try {
    const txHash = await injectedProvider.request({
      method: "eth_sendTransaction",
      params: [transactionParameters],
    });
    console.log("Transaction sent. Hash:", txHash);
    return txHash;
  } catch (error) {
    console.error("Failed to send transaction:", error);
    return null;
  }
}
				
			

Usage example

javascript

				
					const txParams = {
  from: "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
  to: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
  gas: "0x76c0", // 30400
  gasPrice: "0x9184e72a000", // 10000000000000
  value: "0x9184e72a", // 2441406250
  data: "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
};
sendTransaction(txParams);
				
			

Deep Linking

WOW Wallet supports deep linking for WalletConnect sessions. Use the following format:

				
					ullawallet://wc?uri=YOUR_WALLETCONNECT_URI_HERE
				
			

Replace `YOUR_WALLETCONNECT_URI_HERE` with the actual WalletConnect URI, making sure to properly encode it.

This documentation should help developers integrate WOW Wallet into their applications. For further assistance or to report issues, please contact our support team.

Scroll to Top

Join the Crypto Elite!

Be the first to know about the latest earning opportunities, crypto strategies, and special offers. Join the WOW EARN community today!

We value your privacy. Your information will remain confidential and only be used to send you the latest updates from WOW EARN.