OpenViSTAI · Agents · Blockchain · Crypto
Menu
Developer Tools

Ether Swr

Ether Swr is a TypeScript React-hook library that wraps SWR to fetch Ethereum and smart-contract data for decentralized applications, cache responses, deduplicate repeated reads and batch RPC requests.

Independent OpenViST project profile, based on linked sources.

Ether Swr — OpenViST project profile in Developer Tools.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when a React dApp needs declarative Ethereum reads with cached state and background refresh, or needs contract data organized around component hooks.

Who it is for

  • Developers building React-based Ethereum dApps.
  • Teams that need to keep on-chain or contract values available in component state.

Documented uses

  • Read Ethereum methods such as account balances or block numbers from React components.
  • Fetch smart-contract values such as ERC-20 balances using a contract address, method and arguments.
  • Group multiple contract reads and reduce duplicate requests within a rendered component tree.
  • Refresh cached values and respond to contract events, with callback-based optimistic updates.
Before you choose

Requirements & limits

  • Contract interactions require the ABI associated with the contract.
  • The README describes stale-while-revalidate behavior: cached data is returned before an on-chain fetch supplies an updated value.
  • The example configures a Web3 provider and ABI mappings through EthSWRConfig; its broader setup uses Web3React and ethers-related packages.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Install Ether-SWR in a project

Add the Ether-SWR package as a dependency.

Before you start

  • A project using Yarn or npm.

Steps

  1. Install with yarn add ether-swr or the command below.

    Documented command
    npm install --save ether-swr
  2. Continue to the README’s Getting Started section for the documented configuration and usage example.

Expected outcome

Ether-SWR is added as a project dependency.

Guide limitations

  • Installation alone does not configure a provider or demonstrate a running application.
Source-based practical guide

Configure Ether-SWR for Ethereum balance data

Set up the documented global fetcher and request ETH and ERC-20 balances in a React app.

Before you start

  • Ether-SWR installed in the project.
  • A Web3Provider and Web3React setup, an injected connector, and an ERC-20 ABI file, as shown in the README example.

Steps

  1. Import useEtherSWR and EthSWRConfig, along with the provider, wallet, and formatting utilities used by the example.

  2. Map the ERC-20 contract address to its ABI in the ABIs configuration.

  3. Inside the connected-wallet branch, wrap the balance components in EthSWRConfig with web3Provider: library, the ABI map, and refreshInterval: 30000.

  4. Use useEtherSWR(['getBalance', account, 'latest']) for the ETH balance and useEtherSWR([address, 'balanceOf', account]) for a token balance.

Expected outcome

The example configures a global fetcher and requests ETH and token balances; mounted keys are set to refresh every 30 seconds.

Guide limitations

  • This describes the README example, not a verified build or execution.
  • Contract calls require the associated ABI to be provided; the example uses a specific DAI contract address.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
15 October 2026
Original website title
aboutlo/ether-swr · Official homepage title · retained in its source language