This library is meant to be useful for developers that work over ethereum to help them to verify contracts.
const bytecodeUtils = require('bytecode-utils');
const utils = bytecodeUtils.init(<http_provider>);
This method check if a deployed contract match bytecode to a contract passed by parameter.
- address - String
- solcVersion - String - Default: 'latest'
- contractCode - String
- contractName - String
- optimized - Numeric - Default: 1
Type: JSON
{
match: true,
msg: 'bytecode and metadata match exactly'
}
This method compiles a contract and process the output for later usage.
- solcVersion - String - Default: 'latest'
- contractCode - String
- contractName - String
- optimized - Numeric - Default: 1
Type: JSON
{
assembly: '', //compiled assembly
bytecode: {
deployed: '', // compiled bytecode
runtime: '', // compiled runtime bytecode,
functional: '', // compiled functional bytecode
},
auxdata: '', // aux data
abi: '', // ABI
opcodes: '', // opcodes
metadata: '', // metadata
swarm: '', // swarm
}
Return the contract bytecode from a deployed contract.
- address - String
Type: String
Return a solc compiler instance from the passed version.
- version - String
Type: Solc instance
Return a solc compiler instance from the passed version.
- _bytecode - String
- _parameterTypes - Array
Type: object
Make usage of truffle-flattener library to insert all imported contracts into one single file. Useful to verify and/or compare bytecode.
- name - String - The name of the contract.
- contractCode - String - The contract code.
- importFiles - Array - The array of contracts to be imported. If you have zeppelin contracts you must install it as a dependency.
Type: Solc instance
(async function () {
await bytecodeUtils.flatten(
'BSGTokenCrowdsale',
fs.readFileSync('./BSGTokenCrowdsale.sol', 'utf8'),
[{
name: 'BSGToken',
code: fs.readFileSync('./BSGToken.sol', 'utf8')
}]
)
})()