const provider = new HDWalletProvider(
""
);
const web3 = new Web3(provider);
(async () => {
const accounts = await web3.eth.getAccounts();
console.log("Attempting to deploy from account:", accounts[0]);
const result = await new web3.eth.Contract(compile.interface)
.deploy({ data: compile.bytecode, arguments: ["Hi there!"] })
.send({ gas: "", from: accounts[0] });
console.log("Contract deployed to:", result.options.address);
provider.engine.stop();
})();
web3deploy
This snippet first loads the HDWalletProvider and Web3 object. It then attempts to deploy a contract to the accounts variable, which has the 0th account data retrieved from the accounts variable. The contract is deployed, and the output shows the address of the contract. Finally, the engine is stopped.
Shortcut: web3.deployprovider
0 Comments
Add Comment
Log in to add a comment