-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.js
40 lines (33 loc) · 908 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
34
35
36
37
38
39
40
const path = require("path");
const fs = require("fs");
const solc = require("solc");
const poutinePath = path.resolve(__dirname, "Poutine.sol");
const source = fs.readFileSync(poutinePath, "utf-8");
const input = {
language: "Solidity",
sources: {
"Poutine.sol": {
content: source
}
},
settings: {
outputSelection: {
"*": {
"*": ["*"]
}
}
}
};
const findImports = (path) => {
return {
"contents": fs.readFileSync(path, "utf-8")
}
};
const output = JSON.parse(solc.compile(JSON.stringify(input), { import: findImports }));
const abi = output.contracts["Poutine.sol"].PTNToken.abi;
const bytecode = output.contracts["Poutine.sol"].PTNToken.evm.bytecode.object;
const artifact = JSON.stringify({ abi, bytecode }, null, 2)
fs.writeFile("Poutine.json", artifact, (err) => {
if (err) throw err
console.log("Artifact contract file saved!")
})