Release Note
New Features
-
Typed
read/writecontract namespacesAdded
contract.readandcontract.writenamespaces for type-safe, ergonomic access to contract methods. Functions are split by state mutability:view/pure(constant call) functions are exposed undercontract.read, while state-changing functions are exposed undercontract.write. When an ABI is declaredas 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
accountoption 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, afromoption sets the caller address (validated); a caller is required — passfromor set a default address on the instance. - Validation errors (argument count, signer, call value, account) surface as promise rejections.
- ABI functions literally named
readorwriteremain 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.
- Call as
-
Added
utils.abi.encodeFunctionDataAdded
utils.abi.encodeFunctionData(funcABI, args)to build smart contract calldata (function selector + encoded parameters). Validates argument count and supports TRON-specific handling oftrcToken(kept in the selector, encoded asuint256). -
Added
transactionBuilder.updateWitnessAdded
transactionBuilder.updateWitness(address, url, options)to create aWitnessUpdateContracttransaction that updates a witness node URL. Validates the address and the URL format / length (≤ 256).
Improvements
-
Dropped
Bufferin favor ofTextEncoder/TextDecoder- Replaced
Buffer-based encoding intronweb,utils/crypto,utils/abiandutils/ethersUtilswithTextEncoder/TextDecoderfor better cross-environment (browser) compatibility. The conversion is byte-for-byte equivalent to the previous behavior.
- Replaced
-
address.fromPrivateKeyaccepts0x-prefixed private keysTronWeb.address.fromPrivateKey(and the underlyingutils.crypto.pkToAddress) now strips a leading0xfrom the private key before deriving the address, so a private key works whether or not it carries the0xprefix.
Changes
- Bump
axiosfrom 1.15.0 to 1.18.0. - Bump dev dependency
nycto 18. - Add overrides for
ws(8.21.0) andserialize-javascript(7.0.5) to pin security-patched versions. buildnow runs the fullbuild:all(esm, cjs, dist).