2020-04-29 01:13:42 -04:00
|
|
|
// Generates Hasher artifact at compile-time using Truffle's external compiler
|
|
|
|
// mechanism
|
|
|
|
const path = require('path')
|
|
|
|
const fs = require('fs')
|
|
|
|
const genContract = require('circomlib/src/mimcsponge_gencontract.js')
|
|
|
|
|
|
|
|
// where Truffle will expect to find the results of the external compiler
|
|
|
|
// command
|
2020-07-31 22:28:14 -04:00
|
|
|
const outputPath = path.join(__dirname, '..', 'build', 'Hasher.json')
|
2020-04-29 01:13:42 -04:00
|
|
|
|
2021-02-11 01:23:18 -05:00
|
|
|
function main() {
|
2020-04-29 01:13:42 -04:00
|
|
|
const contract = {
|
|
|
|
contractName: 'Hasher',
|
|
|
|
abi: genContract.abi,
|
2021-02-11 01:23:18 -05:00
|
|
|
bytecode: genContract.createCode('mimcsponge', 220),
|
2020-04-29 01:13:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fs.writeFileSync(outputPath, JSON.stringify(contract))
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|