@xjshutu/baip-sdk-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.31 • Public • Published

baip-sdk-js

应用集成平台BAIP,提供JS SDK开发接口,开发者在JS应用中通过调用JS SDK接口,进行区块链能力集成。

安装

npm install @xjshutu/baip-sdk-js

使用方法

const { Conflux } = require('baip-sdk-js');
const PRIVATE_KEY = '0xb05b55c6b7623803eb228f054574fb79fb54c2cb58d370552976fe48b1ac78e0';

const appKey = '4c6323ec72d24dd38c475719916de8e6';
const secret = '240b93c71e0f42f099b59f518b1862d9';

//初始化
const cfx = new Conflux({
    url: 'http://192.168.1.24:16666',
    contractId: '7701ce54-e02c-4236-a1c3-7d76083f3b4e',
    blockchainId: '1074998491917058048',
    appKey,
    secret
  });
//通过私钥获取用户信息
  const account = cfx.Account(PRIVATE_KEY);

  //获取合约信息同时也会获取token
  const contract = cfx.Contract();

  // 交易签名并发送签名后的交易
  const promise = await cfx.sendTransaction({
    data: contract.name().data,
    from: account,
  });
  const txHash = await promise;

API介绍

Conflux

创建Conflux 实例

参数
  • url BAIP地址
  • to 交易方地址
  • contractId 使用的合约id
  • blockchainId 使用的区块链Id
  • appKey 开发者的appKey
  • cert 开发者证书
方法
  • Account(String privateKey) 账户构造函数 传入私钥获取。
  • Contract() 返回合约信息
  • sendTransaction(data,from,...other) 签名并且发送交易信息

Readme

Keywords

none

Package Sidebar

Install

npm i @xjshutu/baip-sdk-js

Weekly Downloads

1

Version

1.0.31

License

ISC

Unpacked Size

66.4 kB

Total Files

40

Last publish

Collaborators

  • zhangjiabin
  • hnxjst