Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 6af068f

Browse files
krzysudanforbes
andauthored
fix: return type of sendTransaction in docs (#7386)
* fix: return type of sendTransaction in docs * Fix Very Minor Typo in Docs --------- Co-authored-by: Dan Forbes <dan.forbes@chainsafe.io>
1 parent 0915cf4 commit 6af068f

File tree

2 files changed

+64
-22
lines changed

2 files changed

+64
-22
lines changed

docs/docs/guides/05_smart_contracts/infer_contract_types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_label: 'Infer Contract Types from JSON Artifact (TypeScript)'
77

88
:::tip
99
📝 This article is for **TypeScript** developers. So, if you are using JavaScript, you do not need to read this.
10-
However, web3.js version 4.x has been rewritten in TypeScript. And we encorage you to use its strongly-typed features with TypeScript.
10+
However, web3.js version 4.x has been rewritten in TypeScript. And we encourage you to use its strongly-typed features with TypeScript.
1111
:::
1212

1313
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.

packages/web3-eth/src/web3_eth.ts

+63-21
Original file line numberDiff line numberDiff line change
@@ -1021,19 +1021,61 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
10211021
* value: '0x1'
10221022
* }
10231023
*
1024-
* const transactionHash = await web3.eth.sendTransaction(transaction);
1025-
* console.log(transactionHash);
1026-
* > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f
1024+
* const transactionReceipt = await web3.eth.sendTransaction(transaction);
1025+
* console.log(transactionReceipt);
1026+
* > {
1027+
* blockHash: '0x39cee0da843293ae3136cee0de4c0803745868b6e72b7cd05fba395bffa0ee85',
1028+
* blockNumber: 6659547n,
1029+
* cumulativeGasUsed: 1029036n,
1030+
* effectiveGasPrice: 6765796845n,
1031+
* from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
1032+
* gasUsed: 21000n,
1033+
* logs: [],
1034+
* logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
1035+
* status: 1n,
1036+
* to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
1037+
* transactionHash: '0x619de868dd73c07bd0c096adcd405c93c1e924fdf741e684a127a52324c28bb9',
1038+
* transactionIndex: 16n,
1039+
* type: 2n
1040+
*}
10271041
*
10281042
* web3.eth.sendTransaction(transaction).then(console.log);
1029-
* > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f
1043+
* > {
1044+
* blockHash: '0x39cee0da843293ae3136cee0de4c0803745868b6e72b7cd05fba395bffa0ee85',
1045+
* blockNumber: 6659547n,
1046+
* cumulativeGasUsed: 1029036n,
1047+
* effectiveGasPrice: 6765796845n,
1048+
* from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
1049+
* gasUsed: 21000n,
1050+
* logs: [],
1051+
* logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
1052+
* status: 1n,
1053+
* to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
1054+
* transactionHash: '0x619de868dd73c07bd0c096adcd405c93c1e924fdf741e684a127a52324c28bb9',
1055+
* transactionIndex: 16n,
1056+
* type: 2n
1057+
*}
10301058
*
10311059
* web3.eth.sendTransaction(transaction).catch(console.log);
10321060
* > <Some TransactionError>
10331061
*
10341062
* // Example using options.ignoreGasPricing = true
10351063
* web3.eth.sendTransaction(transaction, undefined, { ignoreGasPricing: true }).then(console.log);
1036-
* > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f
1064+
* > {
1065+
* blockHash: '0x39cee0da843293ae3136cee0de4c0803745868b6e72b7cd05fba395bffa0ee85',
1066+
* blockNumber: 6659547n,
1067+
* cumulativeGasUsed: 1029036n,
1068+
* effectiveGasPrice: 6765796845n,
1069+
* from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
1070+
* gasUsed: 21000n,
1071+
* logs: [],
1072+
* logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
1073+
* status: 1n,
1074+
* to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
1075+
* transactionHash: '0x619de868dd73c07bd0c096adcd405c93c1e924fdf741e684a127a52324c28bb9',
1076+
* transactionIndex: 16n,
1077+
* type: 2n
1078+
*}
10371079
* ```
10381080
*
10391081
*
@@ -1042,24 +1084,24 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
10421084
* ```ts
10431085
* web3.eth.sendTransaction(transaction).on('sending', transactionToBeSent => console.log(transactionToBeSent));
10441086
* > {
1045-
* from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
1046-
* to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C',
1047-
* value: '0x1',
1048-
* gasPrice: '0x77359400',
1049-
* maxPriorityFeePerGas: undefined,
1050-
* maxFeePerGas: undefined
1087+
* from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
1088+
* to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C',
1089+
* value: '0x1',
1090+
* gasPrice: '0x77359400',
1091+
* maxPriorityFeePerGas: undefined,
1092+
* maxFeePerGas: undefined
10511093
* }
10521094
* ```
10531095
* - `sent`
10541096
* ```ts
10551097
* web3.eth.sendTransaction(transaction).on('sent', sentTransaction => console.log(sentTransaction));
10561098
* > {
1057-
* from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
1058-
* to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C',
1059-
* value: '0x1',
1060-
* gasPrice: '0x77359400',
1061-
* maxPriorityFeePerGas: undefined,
1062-
* maxFeePerGas: undefined
1099+
* from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
1100+
* to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C',
1101+
* value: '0x1',
1102+
* gasPrice: '0x77359400',
1103+
* maxPriorityFeePerGas: undefined,
1104+
* maxFeePerGas: undefined
10631105
* }
10641106
* ```
10651107
* - `transactionHash`
@@ -1090,8 +1132,8 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
10901132
* ```ts
10911133
* web3.eth.sendTransaction(transaction).on('confirmation', confirmation => console.log(confirmation));
10921134
* > {
1093-
* confirmations: 1n,
1094-
* receipt: {
1135+
* confirmations: 1n,
1136+
* receipt: {
10951137
* transactionHash: '0xb4a3a35ae0f3e77ef0ff7be42010d948d011b21a4e341072ee18717b67e99ab8',
10961138
* transactionIndex: 0n,
10971139
* blockNumber: 5n,
@@ -1105,8 +1147,8 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
11051147
* status: 1n,
11061148
* effectiveGasPrice: 2000000000n,
11071149
* type: 0n
1108-
* },
1109-
* latestBlockHash: '0xb57fbe6f145cefd86a305a9a024a4351d15d4d39607d7af53d69a319bc3b5548'
1150+
* },
1151+
* latestBlockHash: '0xb57fbe6f145cefd86a305a9a024a4351d15d4d39607d7af53d69a319bc3b5548'
11101152
* }
11111153
* ```
11121154
* - `error`

0 commit comments

Comments
 (0)