genlayer-js 0.27.7 → 0.27.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +17 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -170,39 +170,44 @@ console.log(trace.genvm_log); // detailed GenVM execution logs
170
170
 
171
171
  ### Using with a wallet provider (MetaMask)
172
172
 
173
- When building a browser dApp, pass the wallet address and EIP-1193 provider. The SDK routes signing operations through the wallet and all reads directly to the GenLayer RPC.
173
+ 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.
174
174
 
175
175
  ```typescript
176
176
  import { createClient } from "genlayer-js";
177
177
  import { testnetBradbury } from "genlayer-js/chains";
178
178
  import { TransactionStatus } from "genlayer-js/types";
179
179
 
180
- // Get address and provider from your wallet connection
181
- const address = "0x..."; // from wallet
182
- const provider = window.ethereum; // or from a wallet SDK
180
+ // Read client talks directly to GenLayer RPC, no wallet needed
181
+ const readClient = createClient({
182
+ chain: testnetBradbury,
183
+ });
183
184
 
184
- const client = createClient({
185
+ // Write client signs transactions through the wallet
186
+ const writeClient = createClient({
185
187
  chain: testnetBradbury,
186
- account: address as `0x${string}`,
187
- provider,
188
+ account: address as `0x${string}`, // from wallet connection
189
+ provider: window.ethereum, // or from a wallet SDK
188
190
  });
189
191
 
190
- // Reads go directly to GenLayer RPC — no wallet involved
191
- const result = await client.readContract({
192
+ // Use readClient for all reads
193
+ const result = await readClient.readContract({
192
194
  address: contractAddress,
193
195
  functionName: "get_storage",
194
196
  args: [],
195
197
  });
196
198
 
197
- // Writes are signed by the wallet (MetaMask popup)
198
- const txHash = await client.writeContract({
199
+ const tx = await readClient.getTransaction({ hash: txHash });
200
+
201
+ // Use writeClient for transactions (MetaMask popup)
202
+ const txHash = await writeClient.writeContract({
199
203
  address: contractAddress,
200
204
  functionName: "update_storage",
201
205
  args: ["new_value"],
202
206
  value: BigInt(0),
203
207
  });
204
208
 
205
- const receipt = await client.waitForTransactionReceipt({
209
+ // Either client can wait for receipts
210
+ const receipt = await readClient.waitForTransactionReceipt({
206
211
  hash: txHash,
207
212
  status: TransactionStatus.ACCEPTED,
208
213
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.27.7",
4
+ "version": "0.27.8",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",