DApp Integration Guide
Anon Wallet injects a standard EIP-1193 provider at window.ethereum. Most DApps that already support MetaMask will work with Anon without any changes.
Detection
Anon sets the following properties on window.ethereum:
window.ethereum.isAnon // true
window.ethereum.isMetaMask // true (for compatibility)
To specifically detect Anon (rather than MetaMask), check isAnon:
if (window.ethereum?.isAnon) {
console.log("Anon Wallet detected");
}
Requesting Accounts
const accounts = await window.ethereum.request({
method: "eth_requestAccounts",
});
// accounts[0] is the user's active public address
The user will see an approval popup listing your DApp's hostname. After approval, the account is returned.
Sending Transactions
const txHash = await window.ethereum.request({
method: "eth_sendTransaction",
params: [{
from: accounts[0],
to: "0xRecipient...",
value: "0xde0b6b3a7640000", // 1 ETH in hex wei
data: "0x",
}],
});
Anon shows the user a transaction approval popup. The user may choose to send from their public balance or (if they have a shielded balance and the appropriate conditions are met) from their private balance.
Signing Messages
// Personal sign
const signature = await window.ethereum.request({
method: "personal_sign",
params: ["Hello from my DApp", accounts[0]],
});
// EIP-712 typed data
const signature = await window.ethereum.request({
method: "eth_signTypedData_v4",
params: [accounts[0], JSON.stringify(typedData)],
});
Network Switching
await window.ethereum.request({
method: "wallet_switchEthereumChain",
params: [{ chainId: "0xa4b1" }], // Arbitrum
});
If the user hasn't configured the requested chain, Anon prompts them to add it.
Event Listeners
// Account changed
window.ethereum.on("accountsChanged", (accounts) => {
console.log("Active account:", accounts[0]);
});
// Chain changed
window.ethereum.on("chainChanged", (chainId) => {
console.log("Chain:", parseInt(chainId, 16));
});
// Connected
window.ethereum.on("connect", ({ chainId }) => {
console.log("Connected to chain:", chainId);
});
Supported Methods
| Method | Supported |
|---|---|
eth_requestAccounts |
✓ |
eth_accounts |
✓ |
eth_sendTransaction |
✓ |
eth_signTransaction |
✓ |
personal_sign |
✓ |
eth_signTypedData_v4 |
✓ |
eth_getBalance |
✓ (enhanced for stealth) |
eth_call |
✓ (enhanced for stealth) |
wallet_switchEthereumChain |
✓ |
wallet_addEthereumChain |
✓ |
wallet_getCapabilities |
✓ (EIP-5792) |
wallet_sendCalls |
✓ (EIP-5792) |
wallet_getCallsStatus |
✓ (EIP-5792) |
Using EIP-5792 (Batch Calls)
For DApps that want to leverage Anon's advanced capabilities (batch transactions, auxiliary funds), use wallet_sendCalls. See Batch Transactions.