-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
32 lines (26 loc) · 1003 Bytes
/
deploy.js
File metadata and controls
32 lines (26 loc) · 1003 Bytes
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
const HDWalletProvider = require("@truffle/hdwallet-provider");
const Web3 = require("web3");
const { abi, evm } = require("./compile");
const dotenv = require("dotenv");
dotenv.config();
const provider = new HDWalletProvider({
// Private key for test wallet. Can also use mnemonic phrase
privateKeys: [process.env.TEST_WALLET_PRIVATE_KEY],
// Link to rinkeby project api endpoint, to allow for deploying to rinkeby network
providerOrUrl: process.env.INFURA_PROJECT_ENDPOINT,
});
const web3 = new Web3(provider);
// Function only to use the async/await syntax
const deploy = async () => {
const accounts = await web3.eth.getAccounts();
console.log("Deploying from account", accounts[0]);
const deploymentResult = await new web3.eth.Contract(abi)
.deploy({
data: evm.bytecode.object,
})
.send({ gas: "1000000", from: accounts[0] });
console.log(abi);
console.log("Contract deployed to:", deploymentResult.options.address);
provider.engine.stop();
};
deploy();