-
Notifications
You must be signed in to change notification settings - Fork 0
/
0.js
39 lines (33 loc) · 1010 Bytes
/
0.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
const dotenv = require('dotenv');
const path = require('path');
const fs = require('fs');
dotenv.config();
var Web3 = require('web3').Web3;
const { PRIVATE_KEY, API_KEY, SOLUTION_0 } = process.env;
const web3 = new Web3(`https://eth-goerli.g.alchemy.com/v2/${API_KEY}`);
// const web3 = new Web3(`http://localhost:8545`);
var bytecode = SOLUTION_0;
// var bytecode = process.argv[2];
var solution = '0';
var abi = require(`./abi/${solution}.json`);
// Second step: add an account to wallet
var account = web3.eth.wallet.add('0x' + PRIVATE_KEY);
console.log('account --->> ', account[0].address);
async function main() {
try {
const contract = new web3.eth.Contract(abi);
console.log('contract --->> ', contract.methods);
const contractDeployed = await contract
.deploy({
input: bytecode,
})
.send({
from: account[0].address,
gas: '1000000',
});
console.log('contract deployed ----->> ', contractDeployed._address);
} catch (error) {
console.error(error);
}
}
main();