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

@makkii/app-tron

v0.1.2

Published

Tron application client implemented makkii-core.

Downloads

9

Readme

@makkii/app-tron

Tron application client.

This library uses some third-party service:

  • Tron Grid API - you can pass in api endpoint in TronApiClient Constructor
  • Explorer Api - To get transaction history, token history, we use https://apilist.tronscan.org/api
  • Transaction Explorer - To show transaction detail page, we use https://tronscan.org/#/transaction

Installation

$ npm install @makkii/app-tron

Usage

import { TronApiClient, TronKeystoreClient, TronLocalSigner } from '@makkii/app-eth';

const api_client = new TronApiClient({
    network: 'mainnet',
    trongrid_api: 'https://api.trongrid.io'
});
api_client.getBalance('TCwypatGAoUhhQCnhuk3hEx8XPJYZ8Wfup')
    .then(console.log)
    .catch(error=>console.log(error));
const keystore_client = new TronKeystoreClient();
api_client.buildTransaction(
    'TCwypatGAoUhhQCnhuk3hEx8XPJYZ8Wfup', // from address
    'TJuJxDPeqbGT8epGAUcZSuMSxy5SC7aYfT', // to address
    0, // amount
).then(function(unsignedTx) {
    keystore_client.signTransaction(unsignedTx, new TronLocalSigner(), {
        private_key: '***'
    }).then(function(signedTx) {
        console.log(signedTx);
    });
});

API

Table of Contents

TronKeystoreClient

signTransaction

Sign transaction by signer

Parameters
  • tx TronUnsignedTx
  • signer T localSigner or hardware
  • signerParam any localSigner: {private_key} hardware:{derivationIndex}
  • unsignedTx unsigned transaction build by buildTransaction

Returns Promise<any> encoded transaction

generateMnemonic

Generate mnemonic by bip39

Returns string 12 length of mnemonic

recoverKeyPairByPrivateKey

Recover key pair by private key

Parameters

Returns Promise<TronKeypair>

validatePrivateKey

Validate private key

not implemented

Parameters

validateAddress

Validate address

Parameters

Returns boolean

getAccountFromMnemonic

Get account from mnemonic

Parameters

Returns Promise<TronKeypair>

getAccountFromHardware

Get account from hardware

not implemented

Parameters
  • _address_index number
  • hardware IHardware

TronUnsignedTx

Tron unsigned transaction

  • to: string;
  • owner: string;
  • amount: number;
  • timestamp: number;
  • expiration: number;
  • latest_block: { hash: string; number: string; };

TronLocalSigner

signTransaction

Sign transaction of tron local signer

Parameters
  • unsignedTx TronUnsignedTx
  • params {} {private_key: string}
  • TronUnsignedTx

Returns any signed tron tx

ITronConfig

network

Network name.

Type: ("mainnet" | "shasta")

trongrid_api

trongrid api

Type: string

explorer_api

explorer_api use to get transactions by address

Type: string

explorer

explorer url that show transaction detail

Type: string

TronPendingTx

Tron pending transaction

  • to: string;
  • from: string;
  • value: BigNumber;
  • timestamp: number;
  • hash: string;
  • status: "PENDING";

TronApiClient

Tron api client that implement IsingleApiClient

Parameters

getNetwork

Get network

Returns any nework mainnet|shasta

updateConfiguration

Update tron api config

Parameters

getBlockByNumber

Get block by number

not implemented

Parameters

getBlockNumber

Get block height

not implemented

getTransactionStatus

Get transaction status by tx hash

Parameters

Returns Promise<TronTxStatus>

getTransactionExplorerUrl

Get an explorer url showing transaction details

Parameters

Returns string url

getBalance

Get an account's balance

Parameters

Returns Promise<BigNumber> balance

sendTransaction

Send transaction

Parameters
  • unsignedTx TronUnsignedTx unsigned transaction build by buildTransaction
  • signer T localSigner or hardware
  • signerParams any localSigner: {private_key} hardware:{derivationIndex}

Returns Promise<TronPendingTx>

sameAddress

check if two address is same

Parameters

Returns boolean

buildTransaction

Build transaction

Parameters

Returns Promise<TronUnsignedTx>

TronTxStatus

Tron transaction status

  • blockNumber: number;
  • status: boolean;

TronTransaction

Tron transaction

  • hash: string;
  • timestamp: number;
  • from: string;
  • to: string;
  • value: BigNumber;
  • blockNumber: number;
  • status: "CONFIRMED" | "FAILED";

TronKeypair

Tron key pair

  • private_key: string;
  • public_key: string;
  • address: string;
  • index?: number;
  • sign?: (hash: any) => Buffer;