@exodus/solana-web3.js

中文文档
1.63.1-exodus.9-rc9发布于 2026/11/05MITTypeScriptES Module近 30 天下载 4.6万

Solana Javascript API

原始使用文档
文档目录18 节
  1. Publishing the library (for Exodus developers)
  2. Documentation and examples
  3. Installation
  4. Yarn
  5. npm
  6. Browser bundle
  7. Development Environment Setup
  8. Run test validator
  9. BPF program development
  10. Usage
  11. Javascript
  12. ES6
  13. Browser bundle
  14. Compatibility
  15. Flow Support (Discontinued)
  16. Releases
  17. Contributing
  18. Disclaimer

Build status codecov
npm npm-downloads
semantic-release code-style-prettier

Solana JavaScript API

This is the Solana Javascript API built on the Solana JSON RPC API

Publishing the library (for Exodus developers)

  1. Ensure the project builds, check types, tests and lint:
$ npm run build && npm run ok
  1. Bump the version in package.json and commit the change:
$ git add package.json && git commit

For the commit message, include the package name and new version in the body. Example:

chore: release

- @exodus/[email protected]
  1. Publish the package:
$ npm publish

Documentation and examples

Installation

Yarn

$ yarn add @solana/web3.js

npm

$ npm install --save @solana/web3.js

Browser bundle

<!-- Development (un-minified) -->
<script src="https://unpkg.com/@solana/web3.js@latest/lib/index.iife.js"></script>

<!-- Production (minified) -->
<script src="https://unpkg.com/@solana/web3.js@latest/lib/index.iife.min.js"></script>

Development Environment Setup

Install the latest Solana release from https://docs.solana.com/cli/install-solana-cli-tools

Run test validator

Use solana-test-validator from the latest Solana release

BPF program development

Use cargo build-bpf from the latest Solana release

Usage

Javascript

const solanaWeb3 = require('@solana/web3.js');
console.log(solanaWeb3);

ES6

import * as solanaWeb3 from '@solana/web3.js';
console.log(solanaWeb3);

Browser bundle

// `solanaWeb3` is provided in the global namespace by the `solanaWeb3.min.js` script bundle.
console.log(solanaWeb3);

Compatibility

This library requires a JavaScript runtime that supports BigInt and the exponentiation operator. Both are supported in the following runtimes:

  • Browsers, by release date:
    • Chrome: May 2018
    • Firefox: July 2019
    • Safari: September 2020
    • Mobile Safari: September 2020
    • Edge: January 2020
    • Opera: June 2018
    • Samsung Internet: April 2019
  • Runtimes, by version:
    • Deno: >=1.0
    • Node: >=10.4.0
  • React Native:

Flow Support (Discontinued)

Flow types are no longer supported in new releases. The last release with Flow support is v1.37.2 and its Flow library definition is provided at https://unpkg.com/@solana/[email protected]/module.flow.js. Download the file and add the following line under the [libs] section of your project's .flowconfig to activate it:

[libs]
node_modules/@solana/web3.js/module.flow.js

Releases

Releases are available on Github and npmjs.com

Each Github release features a tarball containing API documentation and a minified version of the module suitable for direct use in a browser environment (<script> tag)

Contributing

If you have an issue to report or would like to contribute a pull request, please do so against the monorepo at https://github.com/solana-labs/solana. We are not able to merge pull requests into the mirror repo https://github.com/solana-labs/solana-web3.js and issues filed there may go unnoticed.

Disclaimer

All claims, content, designs, algorithms, estimates, roadmaps, specifications, and performance measurements described in this project are done with the Solana Foundation's ("SF") best efforts. It is up to the reader to check and validate their accuracy and truthfulness. Furthermore nothing in this project constitutes a solicitation for investment.

Any content produced by SF or developer resources that SF provides, are for educational and inspiration purposes only. SF does not encourage, induce or sanction the deployment, integration or use of any such applications (including the code comprising the Solana blockchain protocol) in violation of applicable laws or regulations and hereby prohibits any such deployment, integration or use. This includes use of any such applications by the reader (a) in violation of export control or sanctions laws of the United States or any other applicable jurisdiction, (b) if the reader is located in or ordinarily resident in a country or territory subject to comprehensive sanctions administered by the U.S. Office of Foreign Assets Control (OFAC), or (c) if the reader is or is working on behalf of a Specially Designated National (SDN) or a person subject to similar blocking or denied party prohibitions.

The reader should be aware that U.S. export control and sanctions laws prohibit U.S. persons (and other persons that are subject to such laws) from transacting with persons in certain countries and territories or that are on the SDN list. As a project based primarily on open-source software, it is possible that such sanctioned persons may nevertheless bypass prohibitions, obtain the code comprising the Solana blockchain protocol (or other project code or applications) and deploy, integrate, or otherwise use it. Accordingly, there is a risk to individuals that other persons using the Solana blockchain protocol may be sanctioned persons and that transactions with such persons would be a violation of U.S. export controls and sanctions law. This risk applies to individuals, organizations, and other ecosystem participants that deploy, integrate, or use the Solana blockchain protocol code directly (e.g., as a node operator), and individuals that transact on the Solana blockchain through light clients, third party interfaces, and/or wallet software.

版本与发布记录

@exodus/solana-web3.js 共发布 50 个版本,首次发布于 2020/11/18;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.63.1-exodus.9-rc9latest2026/11/059 天前
1.63.1-exodus.9-rc82026/11/059 天前
1.63.1-exodus.9-rc72025/07/041.4 年前
1.63.1-exodus.9-rc62025/07/031.4 年前
1.63.1-exodus.9-rc52025/07/031.4 年前
1.63.1-exodus.9-rc42024/10/102 年前

关于 @exodus/solana-web3.js 的常见问题

@exodus/solana-web3.js 是什么?

Solana Javascript API

如何安装 @exodus/solana-web3.js?

在项目目录运行 npm install @exodus/solana-web3.js,或使用 pnpm add / yarn add / bun add。

@exodus/solana-web3.js 支持 TypeScript 吗?

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

@exodus/solana-web3.js 支持 ESM 还是 CommonJS?

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

@exodus/solana-web3.js 需要什么版本的 Node.js?

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

@exodus/solana-web3.js 可以商用吗?

@exodus/solana-web3.js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@exodus/solana-web3.js 的下载量有多少?

根据 npm 官方下载统计,@exodus/solana-web3.js 在 2026/10/14 – 2026/11/12 这 30 天内被下载 46,361 次,日均约 1,545 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@exodus/solana-web3.js 还在维护吗?

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