@blockscout/app-sdk

中文文档
1.0.1发布于 2026/10/21SEE LICENSE IN ./LICENSETypeScriptES Module构建来源已验证近 30 天下载 2796

A React SDK for Blockscout integration

原始使用文档
文档目录14 节
  1. Features
  2. Installation
  3. Usage
  4. 1. Transaction Toast Notifications
  5. 2. Transaction History Popup
  6. Features
  7. Transaction Toast
  8. Transaction Popup
  9. Chain Compatibility
  10. API Reference
  11. useNotification Hook
  12. useTransactionPopup Hook
  13. Contributing
  14. License

Blockscout UI SDK

A React SDK for integrating Blockscout transaction notifications and transaction history into your dApp.

Features

  • Transaction Toast Notifications
  • Transaction History Popup
  • Transaction interpretation and summaries
  • Support for multiple chains
  • Mobile-responsive design

Installation

npm install @blockscout/app-sdk
# or
yarn add @blockscout/app-sdk

Usage

1. Transaction Toast Notifications

The transaction toast feature provides real-time notifications for transaction status updates. It shows pending, success, and error states with detailed transaction information.

Setup

Wrap your application with the NotificationProvider:

import { NotificationProvider } from "@blockscout/app-sdk";

function App() {
  return (
    <NotificationProvider>
      <YourApp />
    </NotificationProvider>
  );
}

Using Transaction Toast

import { useNotification } from "@blockscout/app-sdk";

function YourComponent() {
  const { openTxToast } = useNotification();

  const handleTransaction = async (txHash) => {
    try {
      // Your transaction logic here
      await sendTransaction();

      // Show transaction toast
      openTxToast("1", txHash); // '1' is the chain ID for Ethereum mainnet
    } catch (error) {
      console.error("Transaction failed:", error);
    }
  };

  return (
    <button onClick={() => handleTransaction("0x123...")}>
      Send Transaction
    </button>
  );
}

2. Transaction History Popup

The transaction history popup allows users to view recent transactions for a specific address or all transactions on a chain.

Setup

Wrap your application with the TransactionPopupProvider:

import { TransactionPopupProvider } from "@blockscout/app-sdk";

function App() {
  return (
    <TransactionPopupProvider>
      <YourApp />
    </TransactionPopupProvider>
  );
}

Using Transaction Popup

import { useTransactionPopup } from "@blockscout/app-sdk";

function YourComponent() {
  const { openPopup } = useTransactionPopup();

  // Show transactions for a specific address
  const showAddressTransactions = () => {
    openPopup({
      chainId: "1", // Ethereum mainnet
      address: "0x123...", // Optional: specific address
    });
  };

  // Show all transactions for a chain
  const showAllTransactions = () => {
    openPopup({
      chainId: "1", // Ethereum mainnet
    });
  };

  return (
    <div>
      <button onClick={showAddressTransactions}>
        View Address Transactions
      </button>
      <button onClick={showAllTransactions}>View All Transactions</button>
    </div>
  );
}

Features

Transaction Toast

  • Real-time status updates (pending, success, error)
  • Transaction interpretation and summaries
  • Links to block explorer
  • Automatic status polling
  • Error handling with revert reasons

Transaction Popup

  • View recent transactions
  • Filter by address
  • Transaction status indicators
  • Transaction interpretation
  • Links to block explorer
  • Mobile-responsive design
  • Loading states and error handling

Chain Compatibility

The SDK is compatible with any blockchain that has a Blockscout explorer instance with API v2 support. These chains are listed in the Chainscout. To verify if your target chain is supported, visit our compatibility checker.

Here are some common supported chain IDs:

  • 1: Ethereum Mainnet
  • 137: Polygon Mainnet
  • 42161: Arbitrum One
  • 10: Optimism

API Reference

useNotification Hook

const { openTxToast } = useNotification();

// Open a transaction toast
openTxToast(chainId: string, hash: string): Promise<void>

useTransactionPopup Hook

const { openPopup } = useTransactionPopup();

// Open transaction popup
openPopup(options: {
  chainId: string;
  address?: string;
}): void

Contributing

This project is currently closed for external contributions. We appreciate your interest, but we are not accepting pull requests at this time.

License

License: Blockscout Software Licence

This project is licensed under the Blockscout Software Licence. See the LICENSE file for full terms.

Third-party components included in this repository remain subject to their own licenses. See dependency manifests and bundled third-party notices for component-level license terms.

版本与发布记录

@blockscout/app-sdk 共发布 23 个版本,首次发布于 2025/05/02;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.1latest2026/10/2118 天前
1.0.02026/10/2019 天前
0.1.22025/06/171.4 年前
0.1.12025/05/311.4 年前
0.1.02025/05/281.4 年前
0.0.1-alpha.202025/05/271.4 年前

关于 @blockscout/app-sdk 的常见问题

@blockscout/app-sdk 是什么?

A React SDK for Blockscout integration

如何安装 @blockscout/app-sdk?

在项目目录运行 npm install @blockscout/app-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@blockscout/app-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blockscout/app-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@blockscout/app-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@blockscout/app-sdk 可以商用吗?

@blockscout/app-sdk 使用 SEE LICENSE IN ./LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@blockscout/app-sdk 的下载量有多少?

根据 npm 官方下载统计,@blockscout/app-sdk 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,796 次,日均约 93 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@blockscout/app-sdk 还在维护吗?

最新版本 1.0.1 发布于 2026/10/21(18 天前);至今共发布 23 个版本,其中过去 12 个月发布了 2 个;首次发布于 2025/05/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。