-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script to calculate contract bytecode
- Loading branch information
1 parent
d78ace7
commit dc4e454
Showing
3 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,24 @@ | ||
// This simple script tells you how big your contract byte code is and how much you have until you exceed | ||
// the current block limit as defined by EIP170. | ||
|
||
const argv = require("minimist")(process.argv.slice(), { string: ["contract"] }); | ||
const contractName = argv.contract; | ||
|
||
if (!contractName) { | ||
console.log("Please enter the contract name as a parameter as `--contract <name>`."); | ||
return; | ||
} | ||
var child = require("child_process").exec("truffle compile"); | ||
child.stdout.pipe(process.stdout); | ||
child.on("exit", function() { | ||
console.log("finished compiling 🚀!"); | ||
console.log("loading", contractName + ".json"); | ||
let obj = require("./../build/contracts/" + contractName + ".json"); | ||
|
||
const byteCodeSize = (obj.bytecode.length - 2) / 2; | ||
const remainingSize = 2 ** 14 + 2 ** 13 - (obj.bytecode.length - 2) / 2; | ||
console.log("Contract is", byteCodeSize, "bytes in size."); | ||
console.log("This leaves a total of", remainingSize, "bytes within the EIP170 limit 🔥."); | ||
|
||
process.exit(); | ||
}); |