Request Network Docs
WebsiteGithubStatusDiscord
  • Request Network Docs
  • Request Network API
    • Create and Pay Requests
    • Crosschain Payments
    • EasyInvoice: API Demo App
    • API Portal: Manage API Keys and Webhooks
      • Manage API Keys and Webhooks programmatically
    • Full API Reference
  • General
    • Lifecycle of a Request
    • Request Scan
    • Supported Chains
      • Smart Contract Addresses
    • Request Network Token List
  • Advanced
    • Request Network SDK
      • Get Started
        • Quickstart - Browser
        • Quickstart - Node.js
        • Installation
        • SDK Injector
        • Request Node Gateways
      • SDK Demo Apps
        • Request Invoicing
          • Pay from Safe Multisig
        • Request Checkout
        • Components
          • Create Invoice Form
          • Invoice Dashboard
          • Payment Widget
          • Add Stakeholder
      • SDK Guides
        • Request Client
          • Configure the Request Client
          • Updating a Request
          • Payment Reference
          • Compute a Request ID without creating the request
          • Use your own signature mechanism
          • Support a new currency
          • In-Memory Requests
        • Encryption and Decryption
          • Encrypt with a wallet signature using Lit Protocol
          • Encrypt with an Ethereum private key
          • Share an encrypted request
        • Payment
          • Detect a payment
          • Native Payment
          • Conversion Payment
          • Declarative Payment
          • Configuring Payment Fees
          • Single Request Forwarder
          • Batch Payment
          • Swap-to-Pay Payment
          • Swap-to-Conversion Payment
          • Transferable Receivable Payment
          • Meta Payments
          • Escrow Payment
          • Streaming Payment
          • Pay through a proxy-contract with a multisig
          • Hinkal Private Payments
        • Mobile using Expo
      • SDK Reference
        • request-client.js
          • RequestNetwork
            • createRequest()
            • computeRequestId()
            • fromRequestId()
            • fromIdentity()
            • fromTopic()
          • Request
            • waitForConfirmation()
            • getData()
            • refresh()
            • cancel()
            • accept()
            • increaseExpectedAmountRequest()
            • reduceExpectedAmountRequest()
          • IIdentity
          • IRequestDataWithEvents
          • PaymentReferenceCalculator
        • payment-processor
          • payRequest()
        • web3-signature
          • Web3SignatureProvider
        • epk-signature
          • EthereumPrivateKeySignatureProvider
        • epk-decryption
          • EthereumPrivateKeyDecryptionProvider
    • Protocol Overview
      • SDK and Request Node Overview
      • Payment Networks
      • Private Requests using Encryption
      • Smart Contracts Overview
    • Internal SDK Architecture
      • Request Logic
      • Advanced Logic
      • Transaction
      • Data-access
      • Storage
      • Data flow
      • Request IPFS network
  • FAQ
  • Glossary
  • Contributing
Powered by GitBook
On this page
  • Overview
  • Key benefits:
  • How it works:

Was this helpful?

Edit on GitHub
Export as PDF
  1. Advanced
  2. Request Network SDK
  3. SDK Guides
  4. Request Client

In-Memory Requests

Overview

In-memory requests allow for creating and managing requests without immediately persisting them to storage. This enables faster payment workflows and deferred persistence.

Key benefits:

  • Faster payment flow: In-memory requests are helpful when payment is the priority, such as in e-commerce cases. In this scenario, the request is a receipt rather than an invoice.

  • Deferred Persistence: With in-memory requests, a request can be created on the front end with a user's signature and passed on to the backend for persistence.

How it works:

The flow of creating and paying an in-memory request is similar to a regular request with the following key differences:

  • Create an in-memory request by passing the argument skipPeristence: true when instantiating the RequestNetwork instance.

  • An in-memory request is not persisted immediately like normal requests. Instead, it is stored in memory on the device where it was created. It can be persisted at a later time using the persistTransaction()function.

  • An in-memory request has the inMemoryInfo property.

  • Avoid calling getData() on an in-memory request because it will fail silently by returning an empty EventEmitter object.

  • Retrieving an in-memory request with requestClient.fromRequestId() will fail because the request has not been persisted yet so it is not possible to read it from the Request Node.

1

Install necessary dependencies

To create in-memory requests, it is necessary to install the following package:

npm install @requestnetwork/request-client.js

Along with the following package for payments:

npm install @requestnetwork/payment-processor
2

Create an in-memory request

Create an in-memory request by passing the argument skipPeristence: true when instantiating the RequestNetwork instance.

// Request parameters 
const requestParameters = {...}


const web3SignatureProvider = new Web3SignatureProvider(
    ethersProvider!.provider
  );

 const inMemoryRequestNetwork = new RequestNetwork({
    nodeConnectionConfig: {
      baseURL: "https://gnosis.gateway.request.network",
    },
    signatureProvider: web3SignatureProvider,
   
  });

 let inMemoryRequest =
    await inMemoryRequestNetwork.createRequest(requestParameters);
3

Pay an in-memory request

To pay an in-memory request, pass the inMemoryInfo.requestData property to the payment function.

import {
  payRequest
} from "@requestnetwork/payment-processor";

const paymentTx = await payRequest(
    inMemoryRequest.inMemoryInfo.requestData,
    signer
  );
  
await paymentTx.wait(confirmationBlocks);
4

Persist in-memory request

In-memory requests need to be persisted using a new RequestNetwork client that does not use the skipPersistence property.

const persistingRequestNetwork = new RequestNetwork({
    nodeConnectionConfig: {
      baseURL: "https://gnosis.gateway.request.network",
    },
  });

await persistingRequestNetwork.persistRequest(inMemoryRequest);
PreviousSupport a new currencyNextEncryption and Decryption

Last updated 3 months ago

Was this helpful?