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() })