Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic deployment script used in a Buidler project
// We require the Buidler Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
// When running the script with `buidler run <script>` you'll find the Buidler
// Runtime Environment's members available in the global scope.
import bre from "@nomiclabs/buidler";
import { Contract, ContractFactory } from "ethers";
async function main(): Promise<void> {
// Buidler always runs the compile task when running scripts through it.
// If this runs in a standalone fashion you may want to call compile manually
// to make sure everything is compiled
// await bre.run('compile');
// We get the contract to deploy
const Greeter: ContractFactory = await bre.ethers.getContract("Greeter");
const greeter: Contract = await Greeter.deploy("Hello, Buidler!");
await greeter.deploy();
console.log("Greeter deployed to: ", greeter.address);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error({ error });
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.