1.5.3 • Published 5 years ago

chain33-rpc-api v1.5.3

Weekly downloads
6
License
ISC
Repository
gitlab
Last release
5 years ago

chain33 接口调用工具

开始使用

npm i chain33-rpc-api -S

工具中不包含promise和fetch的pollyfill, 请根据使用环境自行引入

https://github.com/matthew-andrews/isomorphic-fetch

npm install --save isomorphic-fetch es6-promise

#####使用示例:获取节点的最新高度:

import BtyBaseSdk from 'chain33-rpc-api'
// 新建一个BtyBaseSdk实例,设置默认请求节点和请求错误处理函数(可选,如果不设置可以在方法返回的promise用catch捕获到错误)
let chain33Rpc = new BtyBaseSdk('https://testnet.bityuan.com/api', (error) => {
   console.log('catch error ' + error)
})
// 获取节点的最新高度
chain33Rpc.getLasterHeader().then(res => {
   if (res.error) throw new Error(res.error)
   const { height } = res.result
   console.log('height', height)
})
// 传入url参数指定请求节点
chain33Rpc.getLasterHeader('https://mainnet.bityuan.com/api').then(res => {
   if (res.error) throw new Error(res.error)
   const { height } = res.result
   console.log('height', height)
})

其它工具

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago