Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@tronscan/tronstation
Advanced tools
Javascript API Library for estimating Tron energy and bandwidth consumption based on Tron network.
Readme
Tron Station SDK - Developer Document
Tron Station SDK is a library for estimating Tron energy and bandwidth consumption based on Tron network. Developers can quickly review energy and bandwidth points information before deploying/triggering a smart contract or make a transaction.
Tron Station SDK is also compatible with frontend frameworks such as:
You can also ship Tron Station SDK in a Chrome extension.
Tron Station SDK - NPM Package
> npm install tronstation
> yarn add tronstation
If you'd like to download and build locally, please follow the steps below.
> git clone https://github.com/TRON-US/tronstation-sdk
> cd tronstation-sdk
> yarn install
> yarn build
> yarn test
> npm install tronweb
> yarn add tronweb
import TronStation from 'tronstation';
import TronWeb from 'tronweb';
const fullNode = new HttpProvider('https://api.trongrid.io');
const solidityNode = new HttpProvider('https://api.trongrid.io');
const eventServer = new HttpProvider('https://api.trongrid.io');
const privateKey = 'your private key';
const tronWeb = new TronWeb(
fullNode,
solidityNode,
eventServer,
privateKey
);
// Constructor params are the tronWeb object and specification on if the net type is on main net or test net/private net
const tronStation = new TronStation(tronWeb);
// If you want to reset or switch node net work, just try to re-config your tronWeb and reset in tronStation sdk.
const newTronWeb = new TronWeb(
fullNode,
solidityNode,
eventServer,
privateKey
);
tronStation.setTronWeb(tronWeb);
TronStation-SDK provides three parts of calculators and some of utils can be used easily to estimate energy, bandwidth and super representatives data. There are also some sample usages provided in test directory.
// 1. Converter between frozen energy and trx amount.
const res = await tronStation.energy.trx2FrozenEnergy(1);
const res = await tronStation.energy.trx2FrozenEnergy(10e5, { unit: 'sun' });
const res = await tronStation.energy.frozenEnergy2Trx(666.74484);
const res = await tronStation.energy.frozenEnergy2Trx(666.74484, { unit: 'sun' });
// 2. Converter between burned energy and trx amount.
const res = await tronStation.energy.trx2BurnedEnergy(1);
const res = await tronStation.energy.trx2BurnedEnergy(10e5, { unit: 'sun' });
const res = await tronStation.energy.burnedEnergy2Trx(10e4);
const res = await tronStation.energy.burnedEnergy2Trx(10e4, { unit: 'sun' });
// 3. Calculator of max energy limit for deploying or triggering contract.
const res = await tronStation.energy.getMaxEnergyLimit('your hex address', 1000);
// 1. Converter between frozen bandwidth points and trx amount.
const res = await tronStation.bp.trx2FrozenBandwidth(1);
const res = await tronStation.bp.trx2FrozenBandwidth(10e5, { unit: 'sun' });
const res = await tronStation.bp.frozenBandwidth2Trx(7300.356788039041);
const res = await tronStation.bp.frozenBandwidth2Trx(7300.356788039041, { unit: 'sun' });
// 2. API for getting account bandwidth.
const res = await tronStation.bp.getAccountBandwidth('4165519569C1A1E81646902142DD56A791DEBCB0D8');
// 1. Calculator for estimating rank and votes reward by votes amount.
// existed SR/Candidate
const res = await tronStation.witness.calculateSrReward(1000, '41928c9af0651632157ef27a2cf17ca72c575a4d21');
// New SR/Candidate
const res = await tronStation.witness.calculateSrReward(1000);
// 2. API for getting current SR reward list.
const res = await tronStation.witness.getSrVoteRewardList();
// 1. Convert between trx and sun.
const res = await tronStation.apis.fromTrx(1);
const res = await tronStation.apis.toTrx(10e5);
// 2. Get account resource by name.
const res = await tronStation.apis.getResourceByName('EnergyWeight');
const res = await tronStation.apis.getResourcesByName(['TotalNetLimit', 'TotalNetWeight']);
// 3. Get proposals by name.
const res = await tronStation.apis.getChainParameterByName('getEnergyFee');
const res = await tronStation.apis.getChainParametersByName(['getTotalEnergyCurrentLimit', 'getEnergyFee']);
FAQs
Javascript API Library for estimating Tron energy and bandwidth consumption based on Tron network.
The npm package @tronscan/tronstation receives a total of 1 weekly downloads. As such, @tronscan/tronstation popularity was classified as not popular.
We found that @tronscan/tronstation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.