Skip to content

Instantly share code, notes, and snippets.

@samlaf
Last active February 23, 2022 20:11
Show Gist options
  • Save samlaf/64f4d8c9b7a2049e1f1d5a8e2a61727c to your computer and use it in GitHub Desktop.
Save samlaf/64f4d8c9b7a2049e1f1d5a8e2a61727c to your computer and use it in GitHub Desktop.
PGA latency benchmark (alchemy vs moralis vs infura)
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;
});
@samlaf
Copy link
Author

samlaf commented Feb 19, 2022

This uses the hardhat default Greeter.sol contract

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment