diff --git a/packages/web3-eth/CHANGELOG.md b/packages/web3-eth/CHANGELOG.md index 9a0c99f76f2..21fa4c5d8a0 100644 --- a/packages/web3-eth/CHANGELOG.md +++ b/packages/web3-eth/CHANGELOG.md @@ -201,6 +201,7 @@ Documentation: - Ensure provider.supportsSubscriptions exists before watching by subscription (#6440) - Fixed param sent to `checkRevertBeforeSending` in `sendSignedTransaction` +- Fixed `defaultTransactionBuilder` for value issue (#6509) ### Added diff --git a/packages/web3-eth/src/utils/transaction_builder.ts b/packages/web3-eth/src/utils/transaction_builder.ts index 04ee6d8a7b3..13edd253330 100644 --- a/packages/web3-eth/src/utils/transaction_builder.ts +++ b/packages/web3-eth/src/utils/transaction_builder.ts @@ -155,7 +155,7 @@ export async function defaultTransactionBuilder(option } if (isNullish(populatedTransaction.value)) { - populatedTransaction.value = '0x'; + populatedTransaction.value = '0x0'; } if (!isNullish(populatedTransaction.data)) { diff --git a/packages/web3-eth/test/unit/default_transaction_builder.test.ts b/packages/web3-eth/test/unit/default_transaction_builder.test.ts index 6199f7e1a3f..0e065806393 100644 --- a/packages/web3-eth/test/unit/default_transaction_builder.test.ts +++ b/packages/web3-eth/test/unit/default_transaction_builder.test.ts @@ -228,7 +228,7 @@ describe('defaultTransactionBuilder', () => { }); describe('should populate value', () => { - it('should populate with 0x', async () => { + it('should populate with 0x0 if not provided', async () => { const input = { ...transaction }; delete input.value; delete input.maxPriorityFeePerGas; @@ -239,7 +239,21 @@ describe('defaultTransactionBuilder', () => { web3Context, fillGasPrice: true, }); - expect(result.value).toBe('0x'); + expect(result.value).toBe('0x0'); + }); + + + it('should not populate with 0x0 if provided', async () => { + const input = { ...transaction }; + delete input.maxPriorityFeePerGas; + delete input.maxFeePerGas; + + const result = await defaultTransactionBuilder({ + transaction: input, + web3Context, + fillGasPrice: true, + }); + expect(result.value).not.toBe('0x0'); }); });