EOSJS中文手册【V20】

在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

Api构造函数

创建一个Api实例对象。

函数原型

new Api(args: object): Api

参数

args:json对象,成员如下:

  • rpc: JsonRpc对象
  • authorityProvider: 授权提供器,未指定时使用rpc
  • abiProvider: Abi提供器,未指定时使用rpc
  • signatureProvider: 签名提供器
  • chainId: 链ID
  • textEncoder: TextEncoder对象,在浏览器中使用时传入null
  • textDecoder: TextDecoder对象,在浏览器中使用时传入null

返回值

返回Api实例。

示例代码

import {Api,JsonRpc,JsSignatureProvider} from 'eosjs'
import { TextDecoder, TextEncoder } from 'text-encoding'

const rpc = new JsonRpc('http://127.0.0.1:8888');
const signatureProvider = new JsSignatureProvider(['....']);
const api = new Api({rpc,signatureProvider,textDecoder: new TextDecoder(), textEncoder: new TextEncoder() })