sendTransaction return contract changes from transaction hash to receipt object in web3.js v4
0 reputation · 27 Feb 2020, 16:11 UTC
When moving an application from web3.js v1.x to v4, the sendTransaction method no longer returns a bare transaction hash string; it resolves to a receipt object. This shift forces a design decision about what "completion" means for downstream callers. A v1-oriented codebase may treat the returned hash as proof of broadcast acceptance, whereas a v4 caller must inspect the receipt and decide whether acceptance requires a non-reverted status or merely inclusion in a block.
The migration is further complicated by version-sensitive receipt fields. In v4, numeric transaction values are commonly represented as bigint, while v1 often used BN or string-shaped values, so strict equality checks and serialization logic can break. Provider compatibility adds another boundary: v4 emphasizes EIP-1193-style providers, so applications relying on legacy send or sendAsync provider methods may need an adapter before the new return contract is even exercised.
Given these differences, what is the safest way to define transaction completion during a v1-to-v4 migration? Should the application treat provider acceptance as completion and handle the receipt asynchronously, or wait for a mined receipt and explicitly check for reversion? How should numeric receipt fields be normalized to avoid bigint and BN mismatches across versions?