@fioprotocol/fiosdk

中文文档
1.10.3发布于 2025/12/04MITTypeScriptCommonJS近 30 天下载 6003

The Foundation for Interwallet Operability (FIO) is a consortium of leading blockchain wallets, exchanges and payments providers that seeks to accelerate blockchain adoption by reducing the risk, complexity, and inconvenience of sending and receiving cryp

原始使用文档
文档目录18 节
  1. Errors with compiling the SDKs
  2. Unable to find tsc
  3. Issues Installing TypeDoc?
  4. Base URL for TestNet
  5. TestNet Monitor Tool
  6. Initializing the SDK
  7. Example Usage in JavaScript
  8. Workflow for using the SDK with TestNet
  9. Creating a test account with FIO tokens
  10. When calling a Signed API call that charges FEES,
  11. Example Code
  12. Generating FIO Keys
  13. Example Usage
  14. Example Key Generation Code
  15. Manually Creating Keys without using the FIO Typescript SDK?
  16. FIO Key Derivation Path:
  17. FIO Key Generation Testing
  18. Check for release versions and details here:

FIO TypeScript SDK

The Foundation for Interwallet Operability (FIO) is a consortium of leading blockchain wallets, exchanges and payments providers that seeks to accelerate blockchain adoption by reducing the risk, complexity, and inconvenience of sending and receiving cryptoassets.

For information on FIO, visit the FIO website.

For information on the FIO Chain, API, and SDKs visit the FIO Protocol Developer Hub.

Technology

The FIO TypeScript SDK is built using tsc, to generate the JavaScript files.

Version

Visit the FIO Protocol Developer Hub to get information on FIO SDK versions. Only use an SDK that has a major version number that matches the current FIO Protocol blockchain major version number (e.g. 1.x.x).

Installing FIO TypeScript SDK

The NPM Version is here:

@fioprotocol/fiosdk

Building FIO TypeScript SDK, manually

required tsc version 4.7.2 git clone http://github.com/fioprotocol/fiosdk_typescript --recursive cd fiosdk_typescript install [email protected] -g npm install tsc (verify on the github that your generated .js matches what is presently in the github repository)

Using yarn

Navigate to the "fiosdk_typescript" folder, run yarn to install its dependencies, then run tsc to compile. Before running the test refer to the "Workflow for using the SDK with TestNet" section of this README.

cd fiosdk_typescript
yarn
tsc
npm test (if you would like to run the unit tests)

Errors with compiling the SDKs

Unable to find tsc

Make sure to install typescript by running, this command in terminal:

sudo npm install -g typescript

Publishing to Node Package Manager (npm) Registry

To publish to npm registry.

  1. Update the version number, for this release. In 'package.json'

  2. If the fioJS library was updated in npm. Also update the fioJS version number. In 'package.json'

  3. Publish to npm:

     cd fiosdk_typescript
     yarn
     tsc
     npm test
     npm publish --access public
    
     (If you have enabled 2FA for authorization and publishing using an authenticator app, you will be asked to enter the 6 digit 2FA OTP during publish.)
    

Further details: http://npmjs.com/ https://docs.npmjs.com/creating-and-publishing-scoped-public-packages

Generating Documentation

TypeDoc is installed as a dev dependency. Documentation is pre-generated and included with the source code. To manually generate the documentation run:

cd fiosdk_typescript
./build_docs.sh

The documentation will appear in the folder "documentation" in the root of the project.

Issues Installing TypeDoc?

If typedoc command is not found, install typedoc using the npm global command:

npm install --global typedoc

Using the SDK

The SDK uses a singleton model requiring initialization in the constructor as these parameters are referenced in subsequent SDK Calls.

Base URL for TestNet

http://testnet.fioprotocol.io/v1/

TestNet Monitor Tool

https://monitor.testnet.fioprotocol.io/

Initializing the SDK

fetch = require('node-fetch')

const fetchJson = async (uri, opts = {}) => {
    return fetch(uri, opts)
}

privateKey/publicKey - the wallet user's private/public keys
baseURL - the base URL to the FIO Protocol blockchain API (e.g., http://testnet.fioprotocol.io/v1/)
fetchjson - a reference to fetchJson - this is the module to use for http post/get calls (see above for an example)
registerMockUrl - the URL of the server used to auto-register FIO names for wallet users. This is only used by wallets that have deployed a central server used to register names on their domain. It is used by the registerOnBehalfOfUser method

constructor(
    privateKey: string,
    publicKey: string,
    baseUrl: string,
    fetchjson: fetchJson,
    registerMockUrl = '',
  )

Example Usage in JavaScript

const fio = require('@fioprotocol/fiosdk');

this.fioSDK = new fio.FIOSDK(privateFioKey, publicFioKey, 'http://testnet.fioprotocol.io/v1/', this.fetchJson, '')

Workflow for using the SDK with TestNet

Most Signed API calls charge fees and require a FIO address that is associated with the user making the call.

Creating a test account with FIO tokens

When running a test you will want to register addresses and transfer funds. But, registering a new address for the first time requires FIO tokens. Therefore, some manual setup is required to associate FIO tokens with a FIO public key. To set up a FIO public key with FIO tokents in a test environment:

  1. Manually create two private/public FIO key pairs
    1. Navigate to the website: https://monitor.testnet.fioprotocol.io
    2. Select the 'Create Keypair' button (top left of the website)
    3. Copy the keypairs and FIO Internal Account
  2. Manually register a FIO address for both of these FIO key pairs.
    1. Navigate to the website: https://monitor.testnet.fioprotocol.io
    2. Select the 'Register Address' button
    3. Type in a FIO address
    4. Paste in one of the public keys (created above)
    5. Select the 'Create' button
    6. Do this for each public key pair (twice). The created FIO address will be in this format, "mytest:fiotestnet"
  3. Manually transfer funds into these FIO addresses.
    1. Navigate to the website: https://monitor.testnet.fioprotocol.io
    2. Select the 'Faucet' button
    3. Paste in one of the public keys (created above)
    4. Select the 'Send Coins' button
    5. Do this for each public key pair (twice)
  4. These FIO public addresses now have funds available for making Signed API calls.
  5. Edit the test script to add these FIO addresses and the private/public FIO key pairs
    1. Edit the privateKey, publicKey, privateKey2, publicKey2, testFioAddressName, testFioAddressName2 variables in the testnet.spec file (/fiofoundation-io-fiosdk/tests/testnet.spec)
  6. Run the tests: npm test

When calling a Signed API call that charges FEES,

Use the following steps to determine the fee and pass it to the signed call.

1. Call getFee to get the fee for the Signed API call
2. Call the API Signed call with the fee

Example Code

Example code is located here:
    \examples

For an example of how to generate keys using the SDK, see the sample project here:
    \examples
        \GenerateFioKeys

For an example on how to instantiate the SDK, and register a fio address.  See the sample project here:
    \examples
        \RegisterFioAddress

FIO Public Keys

The SDK provides calls to generate FIO Public Key.

Generating FIO Keys

Private key generation in the SDK is available for testing purposes only. Do not generate private keys for production application using these methods. Instead pass securely generated private keys or seed phrase to the SDK constructor. The user's FIO private/public key can be generated by calling these methods on the sdk:

createPrivateKeyMnemonic OR createPrivateKey
AND
derivedPublicKey

Example Usage

For an example of how to generate keys using the SDK, see the sample project here:
    \examples
        \GenerateFioKeys

Example Key Generation Code

using npm, create a javascript file ('index.js), and run "node index.js"

i.e. JavaScript code ('index.js):

const fio = require('@fioprotocol/fiosdk');
const mnemonic = 'valley alien library bread worry brother bundle hammer loyal barely dune brave'

async function genKeysFromMnemonic () {

    console.log("")
    console.log("From This Mnemonic:")
    console.log(mnemonic)
    console.log("")

    // Private key generation in the SDK is available for testing purposes only. Do not generate private keys for production application using these methods. Instead pass securely generated private keys or seed phrase to the SDK constructor.
    const privateKeyRes = await fio.FIOSDK.createPrivateKeyMnemonic(mnemonic)
    console.log("private key generated:")
    console.log((privateKeyRes.fioKey))
    console.log("")

    const publicKeyRes = fio.FIOSDK.derivedPublicKey(privateKeyRes.fioKey)
    console.log("public key generated")
    console.log((publicKeyRes.publicKey))
    console.log("")
}

genKeysFromMnemonic()

Manually Creating Keys without using the FIO Typescript SDK?

The following information can be used to manually generate FIO keys:

FIO Keys use SLIP-235 for BIP-0044. https://github.com/satoshilabs/slips/blob/master/slip-0044.md

Following the EOS example of private and public key generation. We replace EOS slip '194' with '235'. And 'EOS' public key prefix with 'FIO'. https://eosio.stackexchange.com/questions/397/generate-eos-keys-from-mnemonic-seed

FIO Key Derivation Path:

"44'/235'/0'/0/0"

FIO Key Generation Testing

Using this mnemonic phrase: "valley alien library bread worry brother bundle hammer loyal barely dune brave"

This is the expected Private Key: "5Kbb37EAqQgZ9vWUHoPiC2uXYhyGSFNbL6oiDp24Ea1ADxV1qnu"

This is the expected Public Key: "FIO5kJKNHwctcfUM5XZyiWSqSTM5HTzznJP9F3ZdbhaQAHEVq575o"

Versions

Check for release versions and details here:

https://github.com/fioprotocol/fiosdk_typescript/releases

版本与发布记录

@fioprotocol/fiosdk 共发布 24 个版本,首次发布于 2019/12/13;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.10.3latest2025/12/0411 个月前
1.10.22025/08/281.2 年前
1.10.12025/07/301.3 年前
1.10.02025/03/121.7 年前
1.9.42024/12/231.9 年前
1.9.32024/07/122 年前

关于 @fioprotocol/fiosdk 的常见问题

@fioprotocol/fiosdk 是什么?

The Foundation for Interwallet Operability (FIO) is a consortium of leading blockchain wallets, exchanges and payments providers that seeks to accelerate blockchain adoption by reducing the risk, complexity, and inconvenience of sending and receiving cryp

如何安装 @fioprotocol/fiosdk?

在项目目录运行 npm install @fioprotocol/fiosdk,或使用 pnpm add / yarn add / bun add。

@fioprotocol/fiosdk 支持 TypeScript 吗?

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

@fioprotocol/fiosdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fioprotocol/fiosdk 可以商用吗?

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

@fioprotocol/fiosdk 的下载量有多少?

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

@fioprotocol/fiosdk 还在维护吗?

最新版本 1.10.3 发布于 2025/12/04(11 个月前);至今共发布 24 个版本,其中过去 12 个月发布了 1 个;首次发布于 2019/12/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。