-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.js
34 lines (27 loc) · 889 Bytes
/
compile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const moulaTokenPath = path.resolve(__dirname, 'contract', 'MoulaToken.sol');
const source = fs.readFileSync(moulaTokenPath, 'utf-8');
var input = {
language: 'Solidity',
sources: {
'MoulaToken.sol': {
content: source
}
},
settings: {
outputSelection: {
'*': {
'*': ['*']
}
}
}
};
var output = JSON.parse(solc.compile(JSON.stringify(input)));
var contract = output.contracts['MoulaToken.sol']['MoulaToken'];
var dirName = 'bin';
const contractByteCodePath = path.join(dirName, 'MoulaToken.bin');
fs.writeFileSync(contractByteCodePath, contract.evm.bytecode.object);
const contractAbiPath = path.join(dirName, 'MoulaToken.abi')
fs.writeFileSync(contractAbiPath, JSON.stringify(contract.abi));