We’ve all been there. Write some Solidity, run your tests and
Transaction reverted. Head scratching ensues, followed by frustration and filling everything up with
console.log, commenting out lines of Solidity code and pulling your hair until something starts to make sense.
There have been some attempts at stack traces or better error messages out there for a while, but they all have significant drawbacks like being tightly tied to a specific toolchain, only covering a minimal portion of what an insightful error message should be, or simply being unreliable.
This is why we’re super stoked to finally release Buidler EVM: a Ganache alternative that includes a fully featured Solidity-aware stack traces implementation.
Buidler EVM is a development network that is built into Buidler and plays nicely with your current tools. It extracts execution information when running your smart contract tests to help you debug more effectively. Some highlights are:
- It’s built on top of an unmodified
ethereumjs-vm, which is the same EVM implementation as Ganache and Remix IDE. No new consensus bugs.
- 8000+ lines of testing code making up 500+ tests just for Buidler EVM.
Buidler EVM has first-class Solidity support. It always knows which smart contracts are being run, what they do exactly and why they fail. When a transaction fails without a reason, Buidler EVM will identify and create a clear error message for the following cases:
- Calling a non-payable function with ETH
- Sending ETH to a contract without a payable fallback function
- Calling a non-existent function when there’s no fallback function
- Calling a function with incorrect parameters
- Calling an external function that doesn’t return the right amount of data
- Calling an external function on a non-contract account
- Failing to execute an external call because of its parameters (e.g. trying to send more ETH than what’s available)
- Calling a library without
- Incorrectly calling a precompiled contract
If you’re using or building a tool that isn’t mentioned here, don’t worry. Buidler is designed around an open ecosystem of plugins and integrating new tools and libraries is easy.
Take Buidler EVM out for a spin! Clone this fork of OpenZeppelin with a failing test that will trigger a stack trace:
git clone https://github.com/nomiclabs/buidler-evm-demo.git
npx buidler test
Check Buidler out and forget your Solidity debugging frustrations today! 👷♀️👷♂️