Socket
Socket
Sign inDemoInstall

zetrix-js-query

Package Overview
Dependencies
52
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    zetrix-js-query

A simple query module for the Zetrix chain.


Version published
Weekly downloads
6
increased by500%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

zetrix-js-query

A simple query module for the Zetrix.

js-standard-style

Install

$ npm install --save zetrix-js-query

Test

The tests can be run with Node.js

$ npm test

Usage

Create zetrix-js-query instance

const Query = require('zetrix-js-query')
const query = new Query({
  host: 'http://node.zetrix.com',
  timeout: 1000 * 60
})

Get account info

const address = 'ZTX3eDic98F4nzwanvx2f1F3deJZzx3jJNzsN'
const accountInfo = await query.getAccountInfo(address)
console.log(accountInfo)

Get account metadata

const address = 'ZTX3eDic98F4nzwanvx2f1F3deJZzx3jJNzsN'
const key = 'test'
const metadata = await query.getMetadata(address, key)
console.log(metadata)

// result:
// {
//   key: 'test',
//   value: 'value',
//   version: 1.0
// }

Get account balance

const address = 'ZTX3eDic98F4nzwanvx2f1F3deJZzx3jJNzsN'
const balance = await query.getBalance(address)
console.log(balance)

// result:
// "100000000000000000"

Get account nonce

const address = 'ZTX3eDic98F4nzwanvx2f1F3deJZzx3jJNzsN'
const nonce = await query.getNonce(address)
console.log(nonce)

// result:
// "0"

Get block info

const blockNumber = '100'
const blockInfo = await query.getBlockInfo(blockNumber)
console.log(blockInfo)

// result:
// {
//  closeTime: '1567997123667055',
//  number: '100',
//  txCount: '',
//  version: '1003' 
// }

Get get latest info

const blockInfo = await query.getLatestInfo()
console.log(blockInfo)

// result:
// {
//  closeTime: '1567997123667055',
//  number: '100',
//  txCount: '',
//  version: '1003' 
// }

Get validators for specific blockNumber

const blockNumber = '100'
const validators = await query.getValidators(blockNumber)
console.log(validators)

Get latest validators

const validators = await query.getLatestValidators()
console.log(validators)


Send transaction


const signedTransactionInfo = {
  items: [{
    transaction_blob: blob,
    signatures: signatures
  }]
}

const hash = await query.sendTransaction(signedTransactionInfo)
console.log(hash)

// result:
// '8bb1d61daac2ac2f7726fe5114d0d3747eedbb0e3764d046b8976f8d614982bb'

FAQs

Last updated on 16 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc