storm3-usv-js

0.0.1 • Public • Published

Storm3

  • 使用

    • 安装
      • npm install storm3-usv-js -D
  • 创建storm3实例

 let Storm3 = require('storm3-usv-js');
 let storm3:Object = new Storm3('http://');
  • 创建地址
let account:Object = storm3.accountCreate('随机字符串');
// 地址
account.address;
// 私钥
account.privateKey
  • 查询地址余额
let balance:Number = await storm3.getBalance('地址');
  • 查询块高
let blockNumber:Number = await storm3.getBlockNumber();
  • 校验地址
let isValidAddress:Boolean = storm3.isValidAddress('地址');
  • 查询块交易
let blockTransactions:Array = await storm3.getTransactionsByBlock(29)
  • 查询交易详情
let transaction:Object = await storm3.getTransaction('交易哈希')
  • 查询交易凭证
let transactionReceipt:Object = await storm3.getTransactionReceipt('交易哈希')
  • 签名交易
 let privateKey = '私钥(带0x)';
 let to = '地址'
  // 通过私钥获取账号
  let account = storm3.privateKeyToAccount(privateKey);
  // 获取nonce
  let nonce = await storm3.getTransactionCount(account.address);
  // 转换私钥
  privateKey = Buffer.from(privateKey.substring(2), 'hex');

  let rawTx = {
    nonce: nonce,
    gasPrice: storm3.utils.toHex(0),
    gasLimit: storm3.utils.toHex(4300000),
    gas: storm3.utils.toHex(41000),
    to: to,
    value: 0,
    data: storm3.utils.toHex('')
  };
  // 使用 Storm3.SignTx 进行转换
  let tx = new Storm3.SignTx(rawTx);
  // 签名
  tx.sign(privateKey);
  let serializedTx = tx.serialize();
  // 发送交易
  let hash = await storm3.fst.sendSignedTransaction('0x' + serializedTx.toString('hex'));
  console.log(hash);

Readme

Keywords

none

Package Sidebar

Install

npm i storm3-usv-js

Weekly Downloads

2

Version

0.0.1

License

ISC

Unpacked Size

6.57 kB

Total Files

6

Last publish

Collaborators

  • longxiansheng