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

@brickglobal/coin_tron

v1.1.2

Published

the tron libs nodejs

Downloads

9

Readme

Tron Lib

npm version npm downloads

Installation

Node.js:

// npm
$ npm install @brickglobal/coin_tron
// yarn
$ yarn add @brickglobal/coin_tron

Creating an Instance

First off, in your javascript file, define TronLib:

const { TronLib } = require('@brickglobal/coin_tron');

ES module

import { TronLib } from "@brickglobal/coin_tron";

When you instantiate TronLib you must provide

  • fullNodeUri
  • privateKey: optional
const tronLib = new TronLib("https://api.nileex.io/")
// or
const tronLib = new TronLib("https://api.nileex.io/", "your private key")

Methods

There are total 4 methods:

1. createAccount

Using to create account

Usage

tronLib.createAccount();

Params

Null

Return

Promise { <pending> }
> {
    privateKey: string,
    publicKey: string,
    address {
      base58: string,
      hex: string,
    }
  }

Example

tronLib.createAccount();

// return
Promise { <pending> }
> {
    address: {
      base58: "TPbBpRXnt6ztse8XkCL******", 
      hex: "4195679F3AAF5211991781D4****",
    }
    privateKey: "08089C24EC3BAEB34254DDF5297CF8F******"
    publicKey:  "04EE63599802B5D31A29C95CC7DF04F427E8F0A124BED9333F3A80404ACFC31276594962656EF******"
  }

2. sendTrx

Sends TRX from one address to another.

| WARNING: Do not use this in any web / user-facing applications. This will expose the private key. | | --- |

Usage

tronLib.sendTrx();

Params

| Parameter | Description | Data Type | | :------------ |:---------------:| -----:| | receiverAddress |Address to send TRX to, converted to a hex string.|Hex String| | amount | Amount of TRX to send (units in SUN) | Integer (units in SUN)| | privateKey|Optionally provide a private key to sign the transaction. If left blank, will use the address associated with the private key.|Hex string|

Return

Promise { <pending> }
> txid: string

Example

const sendtrx = await tronLib.sendTrx("TPbBpRXnt6ztse8XkCL******",1000000)
// or
const sendtrx = await tronLib.sendTrx("TPbBpRXnt6ztse8XkCL******",1000000, 'your private key')

// return
Promise { <pending> }
> 456f9e1090dc8ad6baf9237db99334d66e7d640b5********

3. sendToken10

Sends TRC10 token from one address to another.

| WARNING: Do not use this in any web / user-facing applications. This will expose the private key. | | --- |

Usage

tronLib.sendToken10();

Params

| Parameter | Description | Data Type | | :------------ |:---------------:| -----:| | receiverAddress |Address to send TRC10 to.|Hex string| | amount | Amount of TRC10 to send. |positive integers| | tokenId | Name of the token, matching the exact capitalization. |string| | privateKey|Optionally provide a private key to sign the transaction. If left blank, will use the address associated with the private key.|Hex string|

Return

Promise { <pending> }
> txid: string

Example

const send_token_10 = await tronLib.sendTrc10("TPbBpRXnt6ztse8XkCL******",1000000, '100010')
// or
const send_token_10 = await tronLib.sendTrc10("TPbBpRXnt6ztse8XkCL******",1000000, '100010', 'your private key')

// return
Promise { <pending> }
> 456f9e1090dc8ad6baf9237db99334d66e7d640b5********

4. sendToken20

Sends TRC20 token from one address to another.

| WARNING: Do not use this in any web / user-facing applications. This will expose the private key. | | --- |

Usage

tronLib.sendToken20();

Params

| Parameter | Description | Data Type | | :------------ |:---------------:| -----:| | receiverAddress |Address to send TRC20 to.|| | amount | Amount of TRC20 to send. |positive integers| | tokenAddress | Contract address. |Hex string| | privateKey|Optionally provide a private key to sign the transaction. If left blank, will use the address associated with the private key.|Hex string|

Return

Promise { <pending> }
> txid: string

Example

const send_token_20 = await tronLib.sendTrc20("TPbBpRXnt6ztse8XkCL******",1000000, 'TUa1qN4ahSW7xzi5MRgA1YT******')
// or
const send_token_20 = await tronLib.sendTrc20("TPbBpRXnt6ztse8XkCL******",1000000, 'TUa1qN4ahSW7xzi5MRgA1YT******', 'your private key')

// return
Promise { <pending> }
> 456f9e1090dc8ad6baf9237db99334d66e7d640b5********