Skip to main content
Version: 6.4.0

Release Note

New Features

  • Typed read / write contract namespaces

    Added contract.read and contract.write namespaces for type-safe, ergonomic access to contract methods. Functions are split by state mutability: view / pure (constant call) functions are exposed under contract.read, while state-changing functions are exposed under contract.write. When an ABI is declared as const, function names and argument types are checked at compile time.

    • Call as contract.read.methodName([arg0, arg1, ...], options) / contract.write.methodName([arg0, arg1, ...], options).
    • The write account option is a private key: its derived address owns and signs the transaction, so a write can be issued from a non-default signer — including on an instance with no default key. A value that is not a private key is rejected; treat it as secret. For reads, a from option sets the caller address (validated); a caller is required — pass from or set a default address on the instance.
    • Validation errors (argument count, signer, call value, account) surface as promise rejections.
    • ABI functions literally named read or write remain callable via the legacy flat surface.
    • Each function is additionally exposed under its full selector, e.g. contract.read['balanceOf(address)'] / contract.write['transfer(address,uint256)'], pinning that exact overload. Namespaces enumerate each method under both its bare name and its selector.
  • Added utils.abi.encodeFunctionData

    Added utils.abi.encodeFunctionData(funcABI, args) to build smart contract calldata (function selector + encoded parameters). Validates argument count and supports TRON-specific handling of trcToken (kept in the selector, encoded as uint256).

  • Added transactionBuilder.updateWitness

    Added transactionBuilder.updateWitness(address, url, options) to create a WitnessUpdateContract transaction that updates a witness node URL. Validates the address and the URL format / length (≤ 256).

Improvements

  • Dropped Buffer in favor of TextEncoder / TextDecoder

    • Replaced Buffer-based encoding in tronweb, utils/crypto, utils/abi and utils/ethersUtils with TextEncoder / TextDecoder for better cross-environment (browser) compatibility. The conversion is byte-for-byte equivalent to the previous behavior.
  • address.fromPrivateKey accepts 0x-prefixed private keys

    • TronWeb.address.fromPrivateKey (and the underlying utils.crypto.pkToAddress) now strips a leading 0x from the private key before deriving the address, so a private key works whether or not it carries the 0x prefix.

Changes

  • Bump axios from 1.15.0 to 1.18.0.
  • Bump dev dependency nyc to 18.
  • Add overrides for ws (8.21.0) and serialize-javascript (7.0.5) to pin security-patched versions.
  • build now runs the full build:all (esm, cjs, dist).