forked from ethereum/solc-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestWrapper.ts
41 lines (33 loc) · 970 Bytes
/
testWrapper.ts
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
41
import specificSolVersion from './index';
import fs from 'fs';
const contractPath = '/Users/hack/Local/bagels-solc-js/test/resources/BasicContract.sol';
const contractAsString = getContractAsString(contractPath);
async function main() {
const solc = await specificSolVersion('0.8.1');
let input = {
language: 'Solidity',
sources: {
['BasicContract']: {
content: contractAsString,
},
},
settings: {
outputSelection: {
'*': {
'*': ['*'],
},
},
},
}
let output = JSON.parse(
solc.compile(JSON.stringify(input)),
)
for (let contractName in output.contracts['BasicContract']) {
console.log('abi: ', output.contracts['BasicContract'][contractName].abi);
console.log('bytecode: ', output.contracts['BasicContract'][contractName].evm.bytecode.object)
}
}
main();
function getContractAsString(contractDir:string) {
return fs.readFileSync(contractDir).toString();
}