Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pages/api-references/genlayer-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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).
Expand Down
3 changes: 3 additions & 0 deletions pages/developers/decentralized-applications/writing-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading