Created
July 26, 2020 13:42
-
-
Save fvictorio/9914dcd8c38bb1b673c7e67bbbe18fbb to your computer and use it in GitHub Desktop.
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
const cbor = require('cbor') | |
const bytecode = '70656e6420696e707574206e6f7465415a54454320617272617920696e646578206973206f7574206f6620626f756e6473a265627a7a7231582011639b922cf661bed862dc70ef7a0a62211ae58261383916450efb20b2fd6a4164736f6c63430005100032' | |
// last two bytes are 0032, interpreted in hex is 50, so length in hex is 100 | |
// the metadata bytes are the last 100 chars, excluding the last 4 which are the size | |
const metadata = bytecode.slice(bytecode.length - 104, bytecode.length - 4) | |
const { solc } = cbor.decode(metadata) | |
console.log(solc.toString('hex')); | |
// this logs 000510, which means solc 0.5.16 was used |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment