-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wallet' of github.com:jasonandjay/Dapp-Learning into wa…
…llet
- Loading branch information
Showing
10 changed files
with
88 additions
and
75 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,12 @@ | |
node index.js | ||
``` | ||
|
||
4. 查看 mempool 中 pending 的交易 | ||
|
||
```sh | ||
node mempool.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const { ethers } = require('ethers'); | ||
require('dotenv').config(); | ||
|
||
async function main() { | ||
const provider = new ethers.WebSocketProvider(`wss://sepolia.infura.io/ws/v3/${process.env.INFURA_ID}`); | ||
|
||
function limitRPCRequest(fn, delay) { | ||
let timer; | ||
return function(){ | ||
if(!timer) { | ||
fn.call(this, ...arguments) | ||
timer = setTimeout(()=>{ | ||
clearTimeout(timer) | ||
timer = null | ||
},delay) | ||
} | ||
} | ||
} | ||
|
||
console.log("begin to listen to pending transactions") | ||
let j = 0 | ||
var finishFlag = false | ||
provider.on("pending", limitRPCRequest(async (txHash) => { | ||
if (txHash && j <= 20) { | ||
// get the detail of transactions | ||
let tx = await provider.getTransaction(txHash); | ||
console.log(`[${(new Date).toLocaleTimeString()}] : ${txHash}`); | ||
console.log(tx); | ||
j++ | ||
}else{ | ||
finishFlag = true | ||
} | ||
}, 1000)); | ||
|
||
} | ||
|
||
// We recommend this pattern to be able to use async/await everywhere | ||
// and properly handle errors. | ||
main() |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
{ | ||
"name": "hardhat-project", | ||
"devDependencies": { | ||
"@nomiclabs/hardhat-ethers": "^2.0.2", | ||
"@nomiclabs/hardhat-waffle": "^2.0.1", | ||
"@openzeppelin/test-helpers": "^0.5.6", | ||
"chai": "^4.3.4", | ||
"ethereum-waffle": "^3.3.0", | ||
"ethers": "^5.3.1", | ||
"hardhat": "^2.4.1", | ||
"hardhat-contract-sizer": "^2.5.0" | ||
"name": "15-nft-blindbox-chainlink-vrf", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@chainlink/contracts": "^0.4.0", | ||
"@nomiclabs/hardhat-etherscan": "^3.0.1", | ||
"@nomiclabs/hardhat-web3": "^2.0.0", | ||
"@openzeppelin/contracts": "^4.5.0", | ||
"dotenv": "^10.0.0" | ||
"dotenv": "^16.4.5", | ||
"hardhat": "^2.22.2" | ||
}, | ||
"devDependencies": { | ||
"@nomicfoundation/hardhat-toolbox": "^5.0.0" | ||
} | ||
} |
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
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
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