# @okxweb3/coin-tron

> A tron SDK for building Web3 wallets and applications.

Latest version **2.4.10** (published 2026-06-03) · LGPL3.0 license · 0 weekly downloads

## Install

```sh
npm install @okxweb3/coin-tron
pnpm add @okxweb3/coin-tron
yarn add @okxweb3/coin-tron
bun add @okxweb3/coin-tron
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.4.10 |
| Published | 2026-06-03 |
| First published | 2023-09-14 |
| Weekly downloads | 0 |
| License | LGPL3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 385 |
| Author | okx |
| Maintainers | xiao.xu, moxixii, martynyan, toringona, linus.wang, debuggor, jjay98, shisilu, npm-okx |
| Keywords | tron, wallet, web3, crypto, blockchain, sdk, transaction, signing, address, private-key |

## Links

- npm: https://www.npmjs.com/package/@okxweb3/coin-tron
- Repository: https://github.com/okx/js-wallet-sdk
- Homepage: https://github.com/okx/js-wallet-sdk#readme
- Issues: https://github.com/okx/js-wallet-sdk/issues
- npm.io page: https://npm.io/package/@okxweb3/coin-tron

## Dependencies (3)

- [@okxweb3/coin-base](https://npm.io/package/@okxweb3/coin-base.md) ^2.0.7
- [@okxweb3/crypto-lib](https://npm.io/package/@okxweb3/crypto-lib.md) 2.0.6
- [@okxweb3/coin-ethereum](https://npm.io/package/@okxweb3/coin-ethereum.md) 2.4.12

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 2.4.10 (latest) — 2026-06-03
- 2.4.0-beta.0 (beta) — 2025-09-30
- 2.4.9 — 2026-01-05
- 2.4.0 — 2025-10-09
- 1.1.0 — 2025-01-15
- 1.0.8-beta.20 — 2024-12-30
- 1.0.8-beta.10 — 2024-12-23
- 1.0.8-beta.4 — 2024-12-16
- 1.0.9 — 2024-11-18
- 1.0.8 — 2024-10-22
- 1.0.7 — 2024-09-04
- 1.0.6 — 2024-08-22
- 1.0.5 — 2024-08-21
- 1.0.4 — 2024-08-08
- 1.0.3 — 2024-08-06
- … 5 more at https://npm.io/package/@okxweb3/coin-tron/versions

## README

# @okxweb3/coin-tron
TRX SDK is used to interact with the TRON blockchain, it contains various functions can be used to web3 wallet.

## Getting Started
**Installing TRX SDK**
```shell
npm install @okxweb3/coin-tron
```

## Using TRX SDK
### Supported Functions

```typescript
- getNewAddress
- getAddressByPublicKey
- validAddress
- signTransaction
- signMessage
- verifyMessage
- ecRecover
- calcTxHash
```

### Get New Address
get new address by private key

```typescript
import { TrxWallet } from "@okxweb3/coin-tron";

let wallet = new TrxWallet()
const params: NewAddressParams = {
  privateKey: 'your privateKey'
};
const addr = await wallet.getNewAddress(params);

// validate address
const ok = await wallet.validAddress({ address: addr });
```

get new address by public key
```typescript
import { TrxWallet } from "@okxweb3/coin-tron";

let wallet = new TrxWallet()
let param = { 
    publicKey: "04b1d67bb2ece28f87f0f8e310456b88b60a13f642ec31face7d8ed6268698eaba8403cffcd8fba39f4995eac50b4846ef49d738e06a7ca6d0ae87374b177dc080" 
}
let addr = await wallet.getAddressByPublicKey(param);

// validate address
const ok = await wallet.validAddress({ address: addr });
```

### Transaction
sign transaction

parameter
* `fromAddress` address, TRX token sender address
* `refBlockBytes` referenced block bytes, pointing to the relevant block.
* `refBlockHash`
* `expiration`
* `timeStamp`
* `toAddress`
* `amount`

```typescript
import { TrxWallet } from "@okxweb3/coin-tron";

let wallet = new TrxWallet()
const latestBlockNumber = new BN(43380069)
const latestBlockHash = base.fromHex("000000000295ed65e60bbc947b30d97a9d89bd5ac030fccc9e227c428fd6ce09")
const refBlockBytes = latestBlockNumber.toBuffer('be', 8)

const timeStamp = Date.parse(new Date().toString())
const params: SignTxParams = {
    privateKey: 'your privateKey',
    data: {
        type: "transfer",
        data: {
            fromAddress: "TGXQHj3fXhEtCmooRgGemCZyHBEQAv6ct8",
            refBlockBytes: base.toHex(refBlockBytes.slice(6,8)),
            refBlockHash: base.toHex(latestBlockHash.slice(8,16)),
            expiration: timeStamp + 3600 * 1000,
            timeStamp: timeStamp,
            toAddress: "TTczxNWoJJ8mZjj9w2eegiSZqTCTfhjd4g",
            amount: "1000000", // 1 TRX = 1000000 sun
        }
    }
};
const signedTx = await wallet.signTransaction(params);

// verify transaction
const param1 = {
    tx: signedTx,
    data: {
        publicKey: "04b1d67bb2ece28f87f0f8e310456b88b60a13f642ec31face7d8ed6268698eaba8403cffcd8fba39f4995eac50b4846ef49d738e06a7ca6d0ae87374b177dc080",
    }
}
const v = await wallet.validSignedTransaction(param1)
```

sign message
```typescript
import { TrxWallet } from "@okxweb3/coin-tron";

let wallet = new TrxWallet()
let message = "hello world";
message = "0x" + Buffer.from(message, "utf8").toString("hex");

const params: SignTxParams = {
    privateKey: "privateKey",
    data: {
        type: "hex",
        message: message
    }
};
const result = await wallet.signMessage(params);
```

calculate tx hash
```typescript
import { TrxWallet } from "@okxweb3/coin-tron";

let wallet = new TrxWallet()
let calcTxHashParams = {
    data: "0a8a010a0221492208da198635d8a6878a40d8f5b6dcc3305a6c081f12680a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412330a1541e0a8eda2daea867c1d783faf73c8a1ed66cf8150121541955abb8287358c929c7d371a8d034c51426743b81880ade20470bfb1b3dcc330124119365eb67e73485f41c9b29095d445c31948c1d06b95c13d36d5520e289a846b07bfa4b1edbc6845f8858321d595adc913f631b665a2b6ad0840ac14c80bb47300",
};

const txHash = await wallet.calcTxHash(calcTxHashParams);
```

## License: LGPL3

---
_Source: https://npm.io/package/@okxweb3/coin-tron · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
