keycard-redeem/scripts/utils.js

20 lines
560 B
JavaScript
Raw Normal View History

2020-05-13 11:23:17 +00:00
const fs = require('fs');
const path = require('path');
2020-05-13 11:23:17 +00:00
const CONTRACTS_PATH="./contracts";
module.exports.loadContractFile = (fileName) => {
let content = fs.readFileSync(path.join(__dirname, CONTRACTS_PATH, fileName), "utf-8");
return content;
2020-05-13 14:39:52 +00:00
};
2020-05-13 11:23:17 +00:00
module.exports.loadContractCode = (contractName) => {
return this.loadContractFile(`${contractName}.bin`);
2020-05-13 14:39:52 +00:00
};
module.exports.loadContract = (web3, contractName) => {
let content = this.loadContractFile(`${contractName}.abi`);
let abi = JSON.parse(content);
return new web3.eth.Contract(abi);
};