Start a Local Blockchain With Anvil

Noah Hein
InstructorNoah Hein

Share this video with your friends

Send Tweet
Published 6 months ago
Updated 4 months ago

We will start up a local blockchain that behaves like Ethereum, allowing us to test and prototype our smart contracts' behavior rapidly. It provides useful features out of the box, such as logging so we can follow the executions as they happen and pre-funded accounts with their corresponding private keys.

Please Be Warry! Never use or send money to the addresses on mainnet Ethereum. These keys are the same every single time. There are sure to be bots waiting to drain these wallets when funds get sent to them.

Noah Hein: [0:00] To deploy our contract, we are going to use the Anvil tool. Anvil is one of the other CLI tools that we installed whenever we originally ran that foundryup command. Up to this point, we have only been using Forge. [0:16] Anvil will create a local blockchain on our computer. To create that service that will run in the background, all we're going to type is anvil. Anvil listens on port 8545, if it's available, and then shows you a bunch of configuration options that we started with. It shows you what our base fee is and then the gas price as well as the gas limit.

[0:44] Here you can see Welcome to Anvil. This is the really good stuff that Anvil gets you, is it prefunds you 10 different accounts, all of which have 10,000 ETH to spend on your fake local blockchain, along with all of the private keys.