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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-tron-sdk

v0.8.0

Published

tron sdk for react native

Readme

react-native-tron-sdk

Overview

The react-native-tron-sdk provides a set of functions for creating, importing, and managing multi-coin wallets on the Tron blockchain. It supports features such as creating wallets with a seed phrase, importing existing wallets, signing messages, and sending transactions.

Table of Contents

Installation

npm install react-native-tron-sdk

Android Only Setup

Since this library relies on TrustWalletCore for MultiCoin Wallet Management,and the it's android releases are hosted on GitHub packages, It needs authentication to download packages.For this You need to have a GPR Token. You can generate a Token via below steps

  • Go to here
  • Name your Token
  • Set Expiration Time to Never
  • Select read:packages
  • Generate Token and copy it.
  • Create a new local.properties file in your Android folder.
  • Paste Below content in it
gpr.user=YOUR_GITHUB_USER_NAME
gpr.key=YOUR_GENERATED_GPR_TOKEN

Usage

Init

Initializes the Tron SDK. You can add your own RPC by using this method Along with RPC url you can add an object containing custom headers to be sent with each request. Each key is a header name and each value is the corresponding header value. You can use this to add an API key or other authentication headers

  • Note: The headers are added to every request made by the SDK
  • By default, the SDK uses the Nile testnet Public RPC URL
//App.tsx or your main entry file
import { init } from 'react-native-tron-sdk';

//Set your own rpc
init('https://YOUR_OWN_RPC');
/*  or add headers */
init('https://YOUR_OWN_RPC', {
  'X-API-KEY': 'My super key',
});

Create a Wallet

Create a new multi-coin wallet with an optional passphrase for encryption:

import { createWallet,createWalletSync } from 'react-native-tron-sdk';
const passphrase = 'my_secure_passphrase';
//Asynchornous method
const wallet = await createWallet(passphrase);
console.log(wallet);

//Synchornous Method
const res = createWalletSync();
console.log(res)

The createWallet function returns an object with privateKey, publicKey, and seedPhrase.

Import a Wallet

Import an existing wallet using the seed phrase and an optional passphrase:

import { importWallet,importWalletSync } from 'react-native-tron-sdk';
const passphrase = 'my_secure_passphrase';
const seedPharse = 'SOME SECREAT RANDOM SECURE SEED';
const wallet = await importWallet(seedPharse, passphrase);
console.log(wallet);

//Synchornous Method
const res = importWalletSync();
console.log(res)

The importWallet function returns the same structure as createWallet.

Sign a Message

Sign a message using a private key:

import { signMessage } from 'react-native-tron-sdk';
const message = 'Hello, Tron!';
const privateKey = 'your_private_key';
const signature = await signMessage(message, privateKey);
console.log(signature);

Send a Transaction

Send a transaction with the specified options: This can be used to send Native TRX Transfer as well as TRC20 Tokens

import { sendTransaction } from 'react-native-tron-sdk';
const txnOptions = {
  owner_address: 'OWNER_ADDRESS',
  to_address: 'TO_ADDRESS',
  amount: 1000, // Amount in SUN
  private_key: 'PRIVATE_KEY',
};
const hash = await sendTransaction(txnOptions);
console.log('Transaction Hash: ', hash);

Sun Conversion

Convert TRX to SUN and SUN to TRX using the provided utility functions:

import { trxToSun, sunToTrx } from 'react-native-tron-sdk';
const trxAmount = 1.5;
const sunAmount = trxToSun(trxAmount);
console.log(`${trxAmount} TRX is equal to ${sunAmount} SUN`);

const convertedTrxAmount = sunToTrx(sunAmount);
console.log(`${sunAmount} SUN is equal to ${convertedTrxAmount} TRX`);

Note

For transaction amounts, 1 TRX is equivalent to 1,000,000 SUN. The SDK includes utility functions for converting between TRX and SUN.

The SDK handles both TRX transactions and TRC20 token transactions. Specify the contract_address in the options to send a TRC20 transaction.

Ensure to handle and securely store private keys and seed phrases to maintain the security of wallets and transactions.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library