Start a Local Blockchain With Anvil

Noah Hein
InstructorNoah Hein
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 2 years 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.

egghead
egghead
~ 16 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today