npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tron-api-cli

v0.0.1

Published

Tron protocol client using trxplorer.io api

Downloads

3

Readme

tron-api-cli

TRON blockchain api client for nodejs and browser

Tron api cli uses trxplorer.io api (https://api.trxplorer.io) to interract with TRON blockchain protocol

Install

yarn install tron-api-cli

Features

  • Query blockchain (blocks, transactions, accounts, representative etc ...)
  • Create transactions for contracts (send trx, freeze/unfreeze trx, vote etc ...)
  • Sign transaction

## Usage example

import tronapi from "tron-api-client"

# Get user transactions
tronapi.account('TXuLKjf8J8aCKgDgA5uczwn1yQNYVPLocY').getTransactions().then((transactions)=>{ console.log(transactions)})

# Send trx with account/pkey (transaction is automatically signed before broadcasting to TRON network)
tronapi.account('TXuLKjf8J8aCKgDgA5uczwn1yQNYVPLocY',pkey).sendTRX({to:'TZuLFjf8J8aCKgDgA5uczwn1yQNYVPLocY',amount:100})

Cli

Kind: global class

new Cli(options)

| Param | Type | | --- | --- | | options | Options |

cli.account(address, pkey) ⇒ AccountCli

Get an instance of account client

Kind: instance method of Cli

| Param | Type | Description | | --- | --- | --- | | address | string | the account address to query | | pkey | string | the account private key (optional) |

cli.accountExists(criteria)

Checks if an account with a name or an address (or both) exists

Kind: instance method of Cli

| Param | Type | Description | | --- | --- | --- | | criteria | AccountExistsCriteria | (see api.trxplorer.io for details) |

cli.witness()

Get an instance of witness client

AccountCli

Kind: global class

new AccountCli(endpoint, address, privateKey)

Account client

| Param | Type | Description | | --- | --- | --- | | endpoint | string | Api endpoint | | address | string | Account address | | privateKey | string | Account private key (optional) |

accountCli.getInfo() ⇒ AccountInfo

Get basic account informations

Kind: instance method of AccountCli

accountCli.getTransactions(criteria)

Get transactions where current account is involved

Kind: instance method of AccountCli

| Param | Type | | --- | --- | | criteria | TransactionCriteria |

accountCli.getAllVotes(criteria)

Get all votes associated to current account

Kind: instance method of AccountCli

| Param | Type | | --- | --- | | criteria | VoteCriteria |

accountCli.getAllFreeze(criteria)

Get all freeze/unfreeze history associated to current account

Kind: instance method of AccountCli

| Param | Type | | --- | --- | | criteria | VoteCriteria |

accountCli.getTokens(criteria)

Get the token balances associated to this account

Kind: instance method of AccountCli

| Param | Type | | --- | --- | | criteria | TokenCriteria |

accountCli.sendTRX(toAddress, amount, pkey) ⇒ TransactionResult

Send an amount of TRX to an address

/!\ It is highly recommended to use this method with an offline signature strategy

Kind: instance method of AccountCli
Returns: TransactionResult - transaction result

| Param | Type | | --- | --- | | toAddress | string | | amount | number | | pkey | string |

accountCli.sendToken(toAddress, tokenName, amount, pkey) ⇒ TransactionResult

Send an amount of the specified token to an address

/!\ It is highly recommended to use this method with an offline signature strategy

Kind: instance method of AccountCli
Returns: TransactionResult - transaction result

| Param | Type | | --- | --- | | toAddress | string | | tokenName | string | | amount | number | | pkey | string |

accountCli.vote()

Vote for representatives

Kind: instance method of AccountCli

accountCli.freeze(amount, duration) ⇒ TransactionResult

Freeze an amount of TRX for a given duration (in days)

/!\ It is highly recommended to use this method with an offline signature strategy

Kind: instance method of AccountCli
Returns: TransactionResult - transaction result

| Param | Type | | --- | --- | | amount | number | | duration | number |

accountCli.unfreeze() ⇒ TransactionResult

Unfreeze the amount of TRX that can be frozen at this time

/!\ It is highly recommended to use this method with an offline signature strategy

Kind: instance method of AccountCli
Returns: TransactionResult - transaction result

accountCli.widthdraw() ⇒ TransactionResult

Withdraw available allowance (for super representatives rewarded for producing blocks)

/!\ It is highly recommended to use this method with an offline signature strategy

Kind: instance method of AccountCli
Returns: TransactionResult - transaction result

accountCli.sign(transaction)

Sign a transaction with provided private key

Kind: instance method of AccountCli

| Param | Type | | --- | --- | | transaction | Transaction |

accountCli.createWitness(url)

Make current account become a witness if possible

Kind: instance method of AccountCli

| Param | Type | Description | | --- | --- | --- | | url | string | representative url |

accountCli.update(name)

Update account informations

Kind: instance method of AccountCli

| Param | Type | Description | | --- | --- | --- | | name | string | the name associated to current account address |

AccountInfo : Object

Kind: global typedef
Properties

| Name | Type | Description | | --- | --- | --- | | balance | number | Current trx balance | | bandwidth | number | current accoutn bandwidth | | frozen | number | amount of frozen trx | | power | number | power associated to account |

TransactionResult : Object

Kind: global typedef
Properties

| Name | Type | Description | | --- | --- | --- | | txId | string | Transaction id (if transaction succeeded) | | success | boolean | transaction succeeded ? | | messageError | string | the error message |

BlockCli

Kind: global class

new BlockCli(endpoint)

Block client

| Param | Type | Description | | --- | --- | --- | | endpoint | string | Api endpoint |

blockCli.getLatest()

Get the latest available block

Kind: instance method of BlockCli

blockCli.addRef(transaction)

Add Bock reference to a transaction

Kind: instance method of BlockCli

| Param | Type | | --- | --- | | transaction | Transaction |

WitnessCli

Kind: global class

new WitnessCli(endpoint)

Witness client

| Param | Type | Description | | --- | --- | --- | | endpoint | string | Api endpoint |

witnessCli.getAll(criteria)

Get all witnesses matching the criteria

Kind: instance method of WitnessCli

| Param | Type | | --- | --- | | criteria | WitnessCriteria |