Created
May 22, 2020 19:35
-
-
Save trung/65d79757d615202690734ea24c908a14 to your computer and use it in GitHub Desktop.
deploy-simple-storage-contract.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- rawTransactionManager.sendRawRequest(privateSignedTx, privateFor); | |
+ let response = web3.eth.currentProvider.send({ | |
+ jsonrpc: "2.0", | |
+ method: "eth_sendRawPrivateTransaction", | |
+ params: [privateSignedTx, { privateFor }], | |
+ id: "1" | |
+ }); | |
+ console.log(response); | |
+ console.log(`\nTransaction Hash = ${response.result}`); | |
+ getTransactionReceiptMined(response.result).then(console.log); | |
} | |
+function getTransactionReceiptMined(txHash, interval) { | |
+ const self = this; | |
+ const transactionReceiptAsync = function(resolve, reject) { | |
+ web3.eth.getTransactionReceipt(txHash, (error, receipt) => { | |
+ if (error) { | |
+ reject(error); | |
+ } else if (receipt == null) { | |
+ setTimeout( | |
+ () => transactionReceiptAsync(resolve, reject), | |
+ interval ? interval : 500); | |
+ } else { | |
+ resolve(receipt); | |
+ } | |
+ }); | |
+ }; | |
+ | |
+ if (Array.isArray(txHash)) { | |
+ return Promise.all(txHash.map( | |
+ oneTxHash => self.getTransactionReceiptMined(oneTxHash, interval))); | |
+ } else if (typeof txHash === "string") { | |
+ return new Promise(transactionReceiptAsync); | |
+ } else { | |
+ throw new Error("Invalid Type: " + txHash); | |
+ } | |
+}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment