Skip to content

Extension Core (Open Source)

GitHub: https://github.com/TronLink/tronlink-extension-core

@tronlink/core is the JavaScript and TypeScript wallet library used by the TronLink extension. Embed it in a wallet application to derive TRON and EVM accounts and sign locally. For a DApp that asks the user’s installed extension to connect or sign, use the extension provider.

Installation

Install the npm package. It includes CommonJS and ES module entry points and TypeScript declarations.

npm install @tronlink/core

See the upstream prerequisites for the required Node.js, pnpm (development) and TypeScript versions. Browser builds need polyfills for Node modules such as buffer, crypto, and stream. Prerequisites · Upstream webpack configuration

Derive a TRON address

Generate a mnemonic, derive the first account’s first address path, then use the derived private key to obtain the address.

import { BaseWallet, TronWallet } from '@tronlink/core';

const wallet = new TronWallet();
const mnemonic = BaseWallet.generateRandomMnemonic();
const path = wallet.derivePath({ accountIndex: 0, addressIndex: 0 });
const privateKey = wallet.derivePrivateKey({ mnemonic, path });
const address = wallet.getAddressBy({ privateKey });

For an EVM address, use EvmWallet and call its derivePath before deriving the key. TRON and EVM account example

Signing

Both wallet classes support transaction, message, and typed-data signing. For TRON, pass a prepared transaction to wallet.signTransaction({ privateKey, data: rawTransaction }). For an EVM transaction, supply the chain configuration and unsigned transaction in data. Signing returns the result locally. Broadcasting is a separate step. TRON signing examples · EVM signing examples

Ledger and usage statistics

Ledger signing requires a browser that exposes navigator.hid. Use LedgerTrxSigner with the device’s TRX app and LedgerEvmSigner with its ETH app.

Importing the package, deriving an address, or signing locally does not start a statistics upload. To send a report, the host calls checkAndReportXY(deps) and supplies the upload callback. The optional userStatistics module groups mainnet activity by day and amount range, using UUIDs assigned to addresses on the device. Privacy and reporting details

Version & License

For the current version, see the package manifest. Apache License 2.0