Skip to content

Instantly share code, notes, and snippets.

@dillansimmons
Last active September 21, 2021 19:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dillansimmons/4b57628bcf014a80ec5818f515a605b8 to your computer and use it in GitHub Desktop.
Save dillansimmons/4b57628bcf014a80ec5818f515a605b8 to your computer and use it in GitHub Desktop.
Calculate cost to upload folder in ETH
/* eslint-disable no-console */
import getFolderSize from 'get-folder-size';
async function checkCost() {
const myFolder = 'dist'; // your prod assets folder: can be folder or zip file
const size = await getFolderSize.loose(myFolder);
console.log(`The project is ${size} bytes large`);
console.log(`Cost: ${675 * size * 10 * (1 / 1000000000)}Eth at 10Gwei`);
console.log(`Cost: ${675 * size * 50 * (1 / 1000000000)}Eth at 50Gwei`);
console.log(`Cost: ${675 * size * 100 * (1 / 1000000000)}Eth at 100Gwei`);
console.log(`Cost: ${675 * size * 150 * (1 / 1000000000)}Eth at 150Gwei`);
console.log(`Cost: ${675 * size * 200 * (1 / 1000000000)}Eth at 200Gwei`);
}
checkCost();
{
"name": "mcok project package.json file",
...
"scripts": {
"cost": "node cost.mjs",
},
...
"devDependencies": {
"get-folder-size": "^3.1.0",
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment