diff --git a/pages/api-references/genlayer-js.md b/pages/api-references/genlayer-js.md index 6b8a52b4..0e98a9c8 100644 --- a/pages/api-references/genlayer-js.md +++ b/pages/api-references/genlayer-js.md @@ -168,6 +168,8 @@ console.log(trace.genvm_log); // detailed GenVM execution logs When building a browser dApp, create two clients: one for reads (no wallet needed) and one for writes (signed by the wallet). This follows the standard viem pattern and keeps concerns separated. +GenLayerJS can sign browser transactions through a standard EIP-1193 wallet provider such as `window.ethereum`. The SDK does not require a MetaMask Snap for this flow. If your app also integrates a separate GenLayer wallet plugin or Snap, treat it as a separate wallet integration path and make it explicit in your UI so users understand why the browser is showing Snap or third-party-wallet warnings. + ```typescript import { createClient } from "genlayer-js"; import { testnetBradbury } from "genlayer-js/chains"; @@ -238,6 +240,15 @@ Available networks: `"localnet"`, `"studionet"`, `"testnetAsimov"`, `"testnetBra > **Note:** If the wallet is on the wrong chain when you call `writeContract`, the SDK will throw a clear error telling you which chain the wallet is on vs. which chain the client expects. Call `client.connect()` to resolve this. +### Wallet provider troubleshooting + +If users report that a dApp is asking for the GenLayer wallet plugin, a MetaMask Snap, or that another wallet extension such as Rabby must be disabled, first check which provider your app is passing to GenLayerJS: + +- For the standard SDK flow, pass the selected wallet's EIP-1193 provider, for example `provider: window.ethereum`, and call `client.connect()` before writing. +- Do not assume `window.ethereum` always points to MetaMask when several wallet extensions are installed. Use your wallet connector's selected provider when possible. +- If you intentionally depend on a Snap or wallet plugin, tell users this is an app-level wallet requirement, not a requirement of `writeContract` itself. +- Keep a read-only client without a wallet provider for `readContract`, `getTransaction`, and receipt polling so read paths still work when the wallet is disconnected or on the wrong chain. + ### Staking Operations The SDK provides staking functionality for validators and delegators on testnet-bradbury (and testnet-asimov). diff --git a/pages/developers/decentralized-applications/writing-data.mdx b/pages/developers/decentralized-applications/writing-data.mdx index 8036b6da..e01fa9ec 100644 --- a/pages/developers/decentralized-applications/writing-data.mdx +++ b/pages/developers/decentralized-applications/writing-data.mdx @@ -135,6 +135,7 @@ import { TransactionStatus } from "genlayer-js/types"; const client = createClient({ chain: studionet, account: walletAddress as `0x${string}`, + provider: window.ethereum, }); // Switch the wallet to the correct network — must be called before writing @@ -158,6 +159,8 @@ Available networks: `"localnet"`, `"studionet"`, `"testnetAsimov"`, `"testnetBra > **Important:** If the wallet is on the wrong chain, the SDK will throw an error telling you which chain the wallet is on vs. which chain the client expects. Always call `client.connect()` before sending transactions. +> **Wallet provider note:** The standard GenLayerJS browser flow uses the selected wallet's EIP-1193 provider, such as `window.ethereum`; it does not require a MetaMask Snap by itself. If your dApp asks users to install a GenLayer wallet plugin or Snap, that requirement comes from the wallet integration you chose, so document it in your app UI and make sure you pass the intended provider when multiple wallet extensions are installed. + ## Error Handling ```typescript