Last active
February 23, 2022 20:11
-
-
Save samlaf/64f4d8c9b7a2049e1f1d5a8e2a61727c to your computer and use it in GitHub Desktop.
PGA latency benchmark (alchemy vs moralis vs infura)
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
import { ethers, deployments, network } from "hardhat"; | |
async function main() { | |
const acct = (await ethers.provider.listAccounts())[0]; | |
const signer = (await ethers.getSigners())[0]; | |
const greeterAddress = (await deployments.get("Greeter")).address; | |
const Greeter = await ethers.getContractFactory("Greeter"); | |
const greeter = Greeter.attach(greeterAddress); | |
console.log("INFURA") | |
console.log("feePerGas(gwei) latency(ms)") | |
for (let feePerGas = 2.5e9; feePerGas < 35e9; feePerGas = Math.ceil(feePerGas * 1.10)) { | |
const now = Date.now() | |
const txRequest = await greeter.setGreeting( | |
"some new msg", | |
{ | |
maxFeePerGas: feePerGas, | |
maxPriorityFeePerGas: feePerGas, | |
nonce: 22 | |
} | |
); | |
console.log(` ${(feePerGas*1e-9).toFixed(3).padEnd(17, ' ')} ${Date.now() - now}`) | |
} | |
} | |
main().catch((error) => { | |
console.error(error); | |
process.exitCode = 1; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uses the hardhat default Greeter.sol contract