Created
May 22, 2020 15:04
-
-
Save PaulRBerg/a7f177c9962c9d7d0c68a92a8eda1073 to your computer and use it in GitHub Desktop.
Basic deployment script used in a Buidler project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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