Skip to content
Open
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
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

## General

* [Advocates Welcome Kit](general/advocates-welcome-kit.md)
* [Lifecycle of a Request](general/lifecycle-of-a-request.md)
* [Request Scan](general/request-scan.md)
* [Supported Chains](general/supported-chains/README.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This approach works well for Node.js environments _without_ access to a Web3 wal
You will learn:

* How to create a request
* How to update a request (coming soon...)
* How to update a request
* How to pay a request
* How to detect a payment
* How to retrieve a user’s requests
Expand Down Expand Up @@ -127,6 +127,23 @@ Altogether it looks like this:

{% @github-files/github-code-block url="https://github.com/RequestNetwork/quickstart-node-js/blob/main/src/createRequest.js" %}

## Update a request

After creating a request, you might need to update it (e.g., to cancel it or adjust the amount). Updates require a `signatureProvider`.

```javascript
const request = await requestClient.fromRequestId('YOUR_REQUEST_ID');

// Payer accepts the request
await request.accept({
type: Types.Identity.TYPE.ETHEREUM_ADDRESS,
value: payerAddress,
});
await request.waitForConfirmation();
```

See the [Updating a Request](../sdk-guides/request-client/updating-a-request.md) guide for more details.

## Pay a request / Detect a payment

First, construct a `RequestNetwork` object and connect it to a Request Node. In this example, we use the Sepolia Request Node Gateway:
Expand Down Expand Up @@ -171,7 +188,31 @@ const payerWallet = new Wallet(
{% endtab %}

{% tab title="viem" %}
Coming soon. Probably involves `publicClientToProvider()` and `walletClientToSigner()`.
```javascript
const { createPublicClient, createWalletClient, http } = require("viem");
const { mainnet } = require("viem/chains");
const { privateKeyToAccount } = require("viem/accounts");
const { providers } = require("ethers");

const publicClient = createPublicClient({
chain: mainnet,
transport: http(process.env.JSON_RPC_PROVIDER_URL),
});

const account = privateKeyToAccount(process.env.PAYER_PRIVATE_KEY);
const walletClient = createWalletClient({
account,
chain: mainnet,
transport: http(process.env.JSON_RPC_PROVIDER_URL),
});

// Convert viem WalletClient to ethers v5 Signer
const provider = new providers.Web3Provider(walletClient.transport, {
chainId: mainnet.id,
name: mainnet.name,
});
const signer = provider.getSigner(account.address);
Comment on lines +209 to +214
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

viem http transport EIP-1193 compatible ethers Web3Provider

💡 Result:

Short answer — use viem's custom transport for an EIP‑1193 provider (like ethers' Web3Provider/window.ethereum) and viem's http transport for JSON‑RPC endpoints. Example patterns:

  • Use an injected EIP‑1193 provider (MetaMask / ethers Web3Provider.window.ethereum) with viem wallet/public clients:
    import { createWalletClient, createPublicClient, custom } from 'viem'
    import { mainnet } from 'viem/chains'

    // EIP‑1193 provider (window.ethereum or providers.Web3Provider(window.ethereum).provider)
    const eip1193 = window.ethereum

    const walletClient = createWalletClient({
    chain: mainnet,
    transport: custom(eip1193),
    })

    const publicClient = createPublicClient({
    chain: mainnet,
    transport: custom(eip1193), // or use http() for a read‑only RPC
    })

  • Use HTTP RPC for a read/backup transport:
    import { createPublicClient, http } from 'viem'
    const publicClient = createPublicClient({
    chain: mainnet,
    transport: http('https://eth-mainnet.g.alchemy.com/v2/<API_KEY>'),
    })

Notes:

  • If you already wrap window.ethereum with ethers' providers.Web3Provider, pass its underlying provider (.provider) or window.ethereum directly to viem's custom transport — viem expects an EIP‑1193 request interface. [1][2][3]

Sources:
[1] viem — Custom transport (EIP‑1193).
[2] viem migration examples (Web3Provider -> custom).
[3] viem http/fallback transport examples.


🌐 Web query:

viem WalletClient to ethers v5 Signer conversion

💡 Result:

Summary — simple approach

  • Wrap the WalletClient's EIP‑1193 transport in an ethers v5 Web3Provider and call getSigner(account.address). This yields an ethers v5 Signer that delegates signing to the same wallet. [1][2][3]

Example (TypeScript)

  • Assumes you have a viem WalletClient instance named walletClient with walletClient.account.address and walletClient.transport (EIP‑1193 provider, e.g. window.ethereum).

import { providers } from "ethers";

function walletClientToEthersSigner(walletClient: any) {
const provider = new providers.Web3Provider(walletClient.transport as any);
return provider.getSigner(walletClient.account.address);
}

Notes

  • If walletClient.transport is window.ethereum (or another EIP‑1193 provider), Web3Provider will work directly. If you only have the account address but not the transport, you must create a provider (e.g., new providers.Web3Provider(window.ethereum)) and then call getSigner(address). [1][2][3]

Sources

  • Wagmi example: converting a viem client to an ethers Signer. [1]
  • viem WalletClient docs (WalletClient, transports, accounts). [2]
  • viem migration guide (Signers → Accounts mapping). [3]

🌐 Web query:

ethers v5 Web3Provider constructor requirements EIP-1193 provider

💡 Result:

Short answer:

  • ethers v5's Web3Provider accepts an "ExternalProvider" that is either a Web3-compatible provider or an EIP‑1193 provider. It will accept one of these provider method signatures (first match used): provider.request(request) → Promise; or legacy provider.sendAsync(request, callback); or provider.send(request, callback). [1]

  • If you supply an EIP‑1193 provider, it should implement the EIP‑1193 request(...) API and the event methods required by EIP‑1193 (on, removeListener, and emit the connect / disconnect / chainChanged / accountsChanged semantics). See the EIP‑1193 spec for the required request signature and event semantics. [2]

Sources:
[1] ethers v5 docs — Web3Provider / ExternalProvider (ethers.js).
[2] EIP‑1193: Ethereum Provider JavaScript API (request, events).


🏁 Script executed:

cat -n docs/advanced/request-network-sdk/get-started/quickstart-node.js.md | sed -n '180,220p'

Repository: RequestNetwork/docs.request.network

Length of output: 1481


Fix the viem-to-ethers conversion; current code will fail at runtime.

The walletClient is created with viem's http() transport (line 206), which is a JSON-RPC transport and not EIP-1193 compatible. Passing it to ethers' Web3Provider constructor (line 210) will fail because Web3Provider expects an EIP-1193 provider with a request() method. The working pattern requires an EIP-1193 compatible transport created with viem's custom() function, not http().

🤖 Prompt for AI Agents
In docs/advanced/request-network-sdk/get-started/quickstart-node.js.md around
lines 209-214, the conversion from a viem WalletClient to an ethers v5 Signer is
incorrect because the WalletClient was created with viem's http() transport (a
JSON-RPC client) which is not EIP-1193 compatible; instead create an
EIP-1193-compatible transport using viem's custom() helper (or otherwise wrap
the transport to expose a request(method, params) function) and use that
EIP-1193 provider instance when constructing ethers.providers.Web3Provider so
provider.getSigner(account.address) works at runtime. Ensure the
WalletClient/provider initialization is switched to the custom() pattern (or an
adapter exposing request) before passing to Web3Provider.

```
{% endtab %}
{% endtabs %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,88 @@
# Updating a Request

After a request is created, it can be updated:
After a request is created, it can be updated by the authorized parties. Each update requires a signature and is persisted to the Request Network.

<table data-full-width="true"><thead><tr><th>Name</th><th>Description</th><th>Role Authorized</th></tr></thead><tbody><tr><td><strong>accept</strong></td><td>accept a request, indicating that it will be paid</td><td>payer</td></tr><tr><td><strong>cancel</strong></td><td>cancel a request</td><td>payee, payer</td></tr><tr><td><strong>reduceExpectedAmount</strong></td><td>reduce the expected amount</td><td>payee</td></tr><tr><td><strong>increaseExpectedAmount</strong></td><td>increase the expected amount</td><td>payer</td></tr><tr><td><strong>addStakeholders</strong></td><td>grant 1 or more third parties access to view an encrypted request</td><td>payee, payer, third party</td></tr></tbody></table>
## Summary of Actions

Feature exists. More docs coming soon...
| Action | Description | Authorized Role |
| :--- | :--- | :--- |
| **accept** | Accept a request, indicating that it will be paid | Payer |
| **cancel** | Cancel a request | Payee or Payer |
| **reduceExpectedAmount** | Reduce the expected amount | Payee |
| **increaseExpectedAmount** | Increase the expected amount | Payer |

## Examples

### Initialize the Request Client

First, retrieve the request you want to update. You must provide a `signatureProvider` to sign the update transactions.

```javascript
const { RequestNetwork, Types } = require("@requestnetwork/request-client.js");

const requestClient = new RequestNetwork({
nodeConnectionConfig: { baseURL: "https://sepolia.gateway.request.network/" },
signatureProvider: epkSignatureProvider, // Required for updates
});

const request = await requestClient.fromRequestId('YOUR_REQUEST_ID');
```

### Accept a Request (Payer)

The payer can accept a request to signal their intention to pay.

```javascript
const updatedRequestData = await request.accept({
type: Types.Identity.TYPE.ETHEREUM_ADDRESS,
value: payerAddress,
});

// Wait for the update to be persisted
await request.waitForConfirmation();
```

### Cancel a Request (Payee or Payer)

Either the payee or the payer can cancel a request.

```javascript
const updatedRequestData = await request.cancel({
type: Types.Identity.TYPE.ETHEREUM_ADDRESS,
value: signerAddress,
});

await request.waitForConfirmation();
```

### Increase Expected Amount (Payer)

The payer can increase the expected amount (e.g., adding a tip or adjusting for additional services).

```javascript
const updatedRequestData = await request.increaseExpectedAmountRequest(
'100000000000000000', // Amount to add in base units (e.g., 0.1 ETH)
{
type: Types.Identity.TYPE.ETHEREUM_ADDRESS,
value: payerAddress,
}
);

await request.waitForConfirmation();
```

### Reduce Expected Amount (Payee)

The payee can reduce the expected amount (e.g., applying a discount).

```javascript
const updatedRequestData = await request.reduceExpectedAmountRequest(
'100000000000000000', // Amount to subtract in base units
{
type: Types.Identity.TYPE.ETHEREUM_ADDRESS,
value: payeeAddress,
}
);

await request.waitForConfirmation();
```
8 changes: 8 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ Yes. See:

<details>

<summary>How can I contribute to the Request Network as an advocate?</summary>

We have an Advocates program where you can earn REQ tokens by contributing to the protocol's growth, documentation, and community. Check out our [Advocates Welcome Kit](general/advocates-welcome-kit.md) to get started!

</details>

<details>

<summary>Does Request Network support private payments?</summary>

Yes. See [hinkal-private-payments.md](advanced/request-network-sdk/sdk-guides/payment/hinkal-private-payments.md "mention")
Expand Down
50 changes: 50 additions & 0 deletions docs/general/advocates-welcome-kit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Advocates Welcome Kit

Welcome to the Request Network Advocates program! We are excited to have you onboard to help us grow the protocol and support the developer community.

## Mission & Vision

**Our Mission:** To rebuild the world of payments by creating a financial layer that is open, decentralized, and interoperable.

**Our Vision:** A world where every transaction is seamless, transparent, and controlled by the users, not by intermediaries.

## Getting Started

As an advocate, your first week is about getting to know the team and the tools.

### 1. Join the Community
* **Discord:** Join our [Discord server](https://discord.gg/request) and introduce yourself in the `#advocates` channel.
* **Twitter/X:** Follow [@RequestNetwork](https://twitter.com/RequestNetwork) for updates.

### 2. Access Your Tools
* **Notion:** You will receive an invite to our private Advocates workspace.
* **Canva:** Access our brand assets and templates for creating content.
* **GitHub:** Star our [repositories](https://github.com/RequestNetwork) and join the discussions.

### 3. Your First Tasks
* Complete your onboarding profile.
* Read the [Technical Documentation](https://docs.request.network).
* Say hello to the team in the private advocate channel.

## Reward Program

Advocates are rewarded in **REQ tokens** based on their monthly contributions.

### Point Categories
1. **Developer Support & Documentation:** GitHub PRs, tutorials, Discord support.
2. **Content & Awareness:** Blog posts, X threads, videos, memes.
3. **Community Engagement & Growth:** AMAs, moderation, onboarding new developers.

### Reward Tiers
* **I'm around (5-9 points):** Share in 10% of the monthly REQ pool.
* **I'm active (10-14 points):** Share in 40% of the monthly REQ pool.
* **I'm a champ (15+ points):** Share in 50% of the monthly REQ pool.

*Total Monthly Pool: $1,200 USD worth of REQ.*

## Support

If you have any questions, reach out to the program managers in Discord or via email at advocates@request.network.

Let's build the future of payments together!