From 2ecc6883a7ae2383a6ce42cdd481dac6df189815 Mon Sep 17 00:00:00 2001 From: Kris Urbas <605420+krzysu@users.noreply.github.com> Date: Wed, 13 Nov 2024 22:02:39 +0100 Subject: [PATCH 1/2] fix: return type of sendTransaction in docs --- packages/web3-eth/src/web3_eth.ts | 84 +++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/packages/web3-eth/src/web3_eth.ts b/packages/web3-eth/src/web3_eth.ts index ba951914e91..6320ff4f524 100644 --- a/packages/web3-eth/src/web3_eth.ts +++ b/packages/web3-eth/src/web3_eth.ts @@ -1021,19 +1021,61 @@ export class Web3Eth extends Web3Context 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f + * const transactionReceipt = await web3.eth.sendTransaction(transaction); + * console.log(transactionReceipt); + * > { + * blockHash: '0x39cee0da843293ae3136cee0de4c0803745868b6e72b7cd05fba395bffa0ee85', + * blockNumber: 6659547n, + * cumulativeGasUsed: 1029036n, + * effectiveGasPrice: 6765796845n, + * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4', + * gasUsed: 21000n, + * logs: [], + * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + * status: 1n, + * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c', + * transactionHash: '0x619de868dd73c07bd0c096adcd405c93c1e924fdf741e684a127a52324c28bb9', + * transactionIndex: 16n, + * type: 2n + *} * * web3.eth.sendTransaction(transaction).then(console.log); - * > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f + * > { + * blockHash: '0x39cee0da843293ae3136cee0de4c0803745868b6e72b7cd05fba395bffa0ee85', + * blockNumber: 6659547n, + * cumulativeGasUsed: 1029036n, + * effectiveGasPrice: 6765796845n, + * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4', + * gasUsed: 21000n, + * logs: [], + * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + * status: 1n, + * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c', + * transactionHash: '0x619de868dd73c07bd0c096adcd405c93c1e924fdf741e684a127a52324c28bb9', + * transactionIndex: 16n, + * type: 2n + *} * * web3.eth.sendTransaction(transaction).catch(console.log); * > * * // Example using options.ignoreGasPricing = true * web3.eth.sendTransaction(transaction, undefined, { ignoreGasPricing: true }).then(console.log); - * > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f + * > { + * blockHash: '0x39cee0da843293ae3136cee0de4c0803745868b6e72b7cd05fba395bffa0ee85', + * blockNumber: 6659547n, + * cumulativeGasUsed: 1029036n, + * effectiveGasPrice: 6765796845n, + * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4', + * gasUsed: 21000n, + * logs: [], + * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', + * status: 1n, + * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c', + * transactionHash: '0x619de868dd73c07bd0c096adcd405c93c1e924fdf741e684a127a52324c28bb9', + * transactionIndex: 16n, + * type: 2n + *} * ``` * * @@ -1042,24 +1084,24 @@ export class Web3Eth extends Web3Context console.log(transactionToBeSent)); * > { - * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4', - * to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C', - * value: '0x1', - * gasPrice: '0x77359400', - * maxPriorityFeePerGas: undefined, - * maxFeePerGas: undefined + * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4', + * to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C', + * value: '0x1', + * gasPrice: '0x77359400', + * maxPriorityFeePerGas: undefined, + * maxFeePerGas: undefined * } * ``` * - `sent` * ```ts * web3.eth.sendTransaction(transaction).on('sent', sentTransaction => console.log(sentTransaction)); * > { - * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4', - * to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C', - * value: '0x1', - * gasPrice: '0x77359400', - * maxPriorityFeePerGas: undefined, - * maxFeePerGas: undefined + * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4', + * to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C', + * value: '0x1', + * gasPrice: '0x77359400', + * maxPriorityFeePerGas: undefined, + * maxFeePerGas: undefined * } * ``` * - `transactionHash` @@ -1090,8 +1132,8 @@ export class Web3Eth extends Web3Context console.log(confirmation)); * > { - * confirmations: 1n, - * receipt: { + * confirmations: 1n, + * receipt: { * transactionHash: '0xb4a3a35ae0f3e77ef0ff7be42010d948d011b21a4e341072ee18717b67e99ab8', * transactionIndex: 0n, * blockNumber: 5n, @@ -1105,8 +1147,8 @@ export class Web3Eth extends Web3Context Date: Wed, 13 Nov 2024 13:52:49 -0800 Subject: [PATCH 2/2] Fix Very Minor Typo in Docs --- docs/docs/guides/05_smart_contracts/infer_contract_types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/guides/05_smart_contracts/infer_contract_types.md b/docs/docs/guides/05_smart_contracts/infer_contract_types.md index b5288412522..4d7c6e3b8c7 100644 --- a/docs/docs/guides/05_smart_contracts/infer_contract_types.md +++ b/docs/docs/guides/05_smart_contracts/infer_contract_types.md @@ -7,7 +7,7 @@ sidebar_label: 'Infer Contract Types from JSON Artifact (TypeScript)' :::tip 📝 This article is for **TypeScript** developers. So, if you are using JavaScript, you do not need to read this. -However, web3.js version 4.x has been rewritten in TypeScript. And we encorage you to use its strongly-typed features with TypeScript. +However, web3.js version 4.x has been rewritten in TypeScript. And we encourage you to use its strongly-typed features with TypeScript. ::: Web3.js is a popular library used for interacting with EVM blockchains. One of its key features is the ability to invoke EVM smart contracts deployed on the blockchain. In this blog post, we will show how to interact with the smart contract in **TypeScript**, with a special focus on how to infer types from JSON artifact files.