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

@lifi/tron-devkit

v1.0.1

Published

Shared Tron development library for LI.FI contract repos — deployment, address helpers, energy estimation

Readme

@lifi/tron-devkit

Shared Tron development library for deploying and interacting with smart contracts on the Tron blockchain. Provides deployment tooling, address helpers, and energy estimation.

Installation

npm install @lifi/tron-devkit

Quick Start

import {
  TronContractDeployer,
  loadForgeArtifact,
  getPrivateKey,
  getTronRpcUrl,
} from '@lifi/tron-devkit'

// 1. Compile your contracts with Forge
// cd your-repo && forge build

// 2. Load artifact and deploy
const deployer = new TronContractDeployer({
  fullHost: getTronRpcUrl('tron'),       // RPC_URL_TRON or TronGrid fallback
  tvmNetworkKey: 'tron',
  privateKey: getPrivateKey(),            // from PRIVATE_KEY env var
})

const artifact = await loadForgeArtifact('MyContract', './out')
const result = await deployer.deployContract(artifact, [/* constructor args */])

console.log(`Deployed to: ${result.contractAddress}`)
console.log(`Cost: ${result.actualCost.trxCost} TRX`)

Environment Variables

| Variable | Required | Description | |----------|----------|-------------| | PRIVATE_KEY | Yes | Deployer private key (hex, with or without 0x) | | RPC_URL_TRON | No | Tron mainnet RPC URL (default: https://api.trongrid.io) | | RPC_URL_TRONSHASTA | No | Tron Shasta testnet RPC URL (default: https://api.shasta.trongrid.io) | | TRONGRID_API_KEY | No | TronGrid API key (reduces rate limiting) |

Core Features

Contract Deployment (TronContractDeployer)

Full deployment lifecycle:

  • Energy + bandwidth estimation via triggerconstantcontract
  • Cost validation against account balance (accounting for delegated resources)
  • Rate-limit retry logic (TronGrid 429 backoff)
  • Receipt confirmation polling
  • Dry-run mode for cost previews
const deployer = new TronContractDeployer({
  fullHost: 'https://api.trongrid.io',
  tvmNetworkKey: 'tron',
  privateKey: '0x...',
  dryRun: false,        // set true for cost preview
  verbose: false,       // set true for debug logging
  safetyMargin: 1.2,   // 20% energy buffer (default)
})

Forge Artifact Loading

Load compiled contract artifacts from Forge output:

import { loadForgeArtifact } from '@lifi/tron-devkit'

// Default: loads from <cwd>/out/<Name>.sol/<Name>.json
const artifact = await loadForgeArtifact('MyContract')

// Custom artifacts directory
const artifact = await loadForgeArtifact('MyContract', '/path/to/out')

Address Conversion

Bidirectional Tron base58 <-> EVM hex conversion:

import {
  tronAddressToHex,
  evmHexToTronBase58,
  tronAddressLikeToBase58,
} from '@lifi/tron-devkit'

// Tron base58 -> EVM hex
const hex = tronAddressToHex(tronWeb, 'TJCnKsPa7y5okkXvQAidZBzqx3QyQ6sxMW')
// -> '0x...'

// EVM hex -> Tron base58
const base58 = evmHexToTronBase58(tronWeb, '0x...')
// -> 'TJCn...'

Energy & Cost Estimation

import {
  estimateContractCallEnergy,
  estimateEnergyAndFeeLimit,
  getCurrentPrices,
} from '@lifi/tron-devkit'

// Get current energy/bandwidth prices
const { energyPrice, bandwidthPrice } = await getCurrentPrices(tronWeb)

// Estimate energy for a contract call
const energy = await estimateContractCallEnergy({
  fullHost: 'https://api.trongrid.io',
  tronWeb,
  contractAddressBase58: 'T...',
  functionSelector: 'transfer(address,uint256)',
  parameterHex: '...',
})

Safe Transaction Broadcasting

For multisig governance workflows:

import { broadcastTronContractCall } from '@lifi/tron-devkit/safe'

const result = await broadcastTronContractCall({
  networkKey: 'tron',
  privateKeyHex: '0x...',
  contractAddress: '0x...',
  calldata: '0x...',
})

Integrating a New Repo

  1. Install the library:

    npm install @lifi/tron-devkit
  2. Compile contracts:

    forge build
  3. Set environment variables:

    export PRIVATE_KEY=0x...
    export RPC_URL_TRON=https://api.trongrid.io  # optional
    export TRONGRID_API_KEY=...                    # optional
  4. Write a deployment script:

    import {
      TronContractDeployer,
      loadForgeArtifact,
      getPrivateKey,
      getTronRpcUrl,
    } from '@lifi/tron-devkit'
    
    const deployer = new TronContractDeployer({
      fullHost: getTronRpcUrl('tron'),
      tvmNetworkKey: 'tron',
      privateKey: getPrivateKey(),
    })
    
    for (const name of ['ContractA', 'ContractB']) {
      const artifact = await loadForgeArtifact(name, './out')
      const result = await deployer.deployContract(artifact)
      console.log(`${name}: ${result.contractAddress}`)
    }
  5. Run it:

    bun run script/tron/deploy.ts

API Reference

Exports from @lifi/tron-devkit

| Export | Description | |--------|-------------| | TronContractDeployer | Main deployment class | | loadForgeArtifact | Load Forge build artifacts | | getPrivateKey | Read PRIVATE_KEY from env | | getTronRpcUrl | Read RPC URL with TronGrid fallback | | tronAddressToHex | Tron base58 -> EVM hex | | evmHexToTronBase58 | EVM hex -> Tron base58 | | createTronWeb | Create TronWeb instance | | createTronWebForTvmNetworkKey | Create TronWeb from network key | | createTronWebReadOnly | Read-only TronWeb (no signing) | | estimateContractCallEnergy | Estimate energy for contract call | | getCurrentPrices | Get energy/bandwidth prices | | tronScanTransactionUrl | Build TronScan TX URL | | formatAddressForNetworkCliDisplay | Format address for CLI output | | isTronNetworkKey | Check if network key is Tron | | TronWalletClient | Wallet wrapper for Safe operations |

Exports from @lifi/tron-devkit/safe

| Export | Description | |--------|-------------| | broadcastTronContractCall | Broadcast arbitrary contract call | | broadcastTronSafeExecTransaction | Broadcast Safe execTransaction |

Tron vs EVM -- Key Differences

| Aspect | EVM | Tron | |--------|-----|------| | Address format | 0x + 40 hex | Base58 (T prefix, 34 chars) | | Gas model | Gas per opcode | Energy + Bandwidth | | RPC | Standard JSON-RPC | TronWeb HTTP API | | Fee unit | Wei (ETH) | SUN (1 TRX = 1,000,000 SUN) | | CREATE2 | Deterministic | Different addresses than EVM | | Rate limits | Varies | TronGrid has aggressive 429s |