WIP: Hevm based debugger for hardhat-huff projects

Overview

Huff Debug

An easy hevm debug integration for hardhat-huff projects

What does it do:

Speed up your development experience by gaining rich feedback in a hevm debugger, step through each opcode of your huff projects line by line to find out what went wrong and spot possible optimizations.

What is hevm

In the words of the developers themselves: The hevm project is an implementation of the Ethereum virtual machine (EVM) made specifically for symbolic execution, unit testing and debugging of smart contracts. It is developed by DappHub and integrates especially well with the dapp tool suite. The hevm command line program can symbolically execute smart contracts, run unit tests, interactively debug contracts while showing the Solidity source, or run arbitrary EVM code. Computations can be performed using local state set up in a dapp testing harness, or fetched on demand from live networks using rpc calls.

More importantly hevm supports an interactive debugger, this allows you to step through execution of arbitrary bytecode line by line, seeing that huff exposes the developer to the evm directly you can essentially debug your huff projects line by line.

Installation

REQUIRED This plugin has a strong dependency in hevm existing within your $PATH. (It wont work at all without it). Before going any further please install it here.

Once that is taken care of, go ahead and install hardhat huff and the huff-debug package using your favourite node package manager:

npm install hardhat-huff huff-debug

Import the plugin in your hardhat.config.js:

require("huff-debug");

Or if you are using TypeScript, in your hardhat.config.ts:

import "huff-debug";

Required plugins

Tasks

huff-debug

This plugin adds the huff-debug task to hardhat.

Usage:

npx hardhat help huff-debug 
Hardhat version 2.8.0

Usage: hardhat [GLOBAL OPTIONS] huff-debug [--reset] [--state] file func args

OPTIONS:

  --reset       Reset hevm state 
  --state       Use maintained hevm state 

POSITIONAL ARGUMENTS:

  file          -- The file name that the target function exists within
  func          -- The function name being targeted
  args          -- Comma separated list of function arguments e.g. - 0x0000000000000000000000000000000000000069,1

huff-debug: 

For global options help run: hardhat help

A huff interface consists of definitions that looks as follows: #define function mint(address,uint256) nonpayable returns () The anatomy of this definition is something like this: function <functionName>(<args>) <decorators>

To run your function with huff-debug simply name your target file, function name and args!

Full example: npx hardhat huff-debug ERC721.huff mint 0x0000000000000000000000000000000000000069,1 This will step through execution of the mint function within your ERC721 huff contract with the args address=0x0000000000000000000000000000000000000069 and amount=1.

Options

--state When debugging you may have a transaction that relys on some existing contract state. A typical example of this would be calling a function with some form of access protection, the most common of these is the onlyOwner modifier for calling sensitive functions. Debugging these calls will ALWAYS fail is you have not provided the state flag as the OWNER will be set to the zero address. Making any future logic unaccessible. Providing the state flag will persist any storage updates that are made. State is stored as a git repository within the cache folder - see the hevm docs for more information.

--reset This flag provides a fresh hevm state, read above for more info on state.

Contributors

Below is only relevant if you are reading this to contribute to the project! For any feature requests please open a github issue, if you want to get your hands dirty feel free to pull and create a pull request!!

Installation

To start working on your project, just run

npm install

Plugin development

Make sure to read our Plugin Development Guide to learn how to build a plugin.

Testing

Running npm run test will run every test located in the test/ folder. They use mocha and chai, but you can customize them.

We recommend creating unit tests for your own modules, and integration tests for the interaction of the plugin with Hardhat and its dependencies.

Linting and autoformat

All of Hardhat projects use prettier and tslint.

You can check if your code style is correct by running npm run lint, and fix it with npm run lint:fix.

Building the project

Just run npm run build 👷

You might also like...

A Bed and Breakfast dApp run on Ethereum. Includes a token + schedule system (Solidity) and full front-end (React + ethers.js) built with Hardhat.

A Bed and Breakfast dApp run on Ethereum. Includes a token + schedule system (Solidity) and full front-end (React + ethers.js) built with Hardhat.

Hotel ETH - Watch Demo Video Hotel ETH A (fictional) Bed-and-Breakfast run on Ethereum Come Book a Room on Kovan or Rinkeby Networks View the Demo » C

Aug 20, 2022

An NFT Marketplace built with NextJS, Hardhat and Solidity

An NFT Marketplace built with NextJS, Hardhat and Solidity

🖼️ NFT Marketplace This is a fullstack DApp NFT Marketplace built as a study project to learn more about blockchain and smart contract development. M

Dec 31, 2022

Hardhat plugin to track gas on the transaction level

Hardhat plugin to track gas on the transaction level

hardhat-gas-trackooor Hardhat plugin to track gas on the transaction level. Example report Installation npm install hardhat-gas-trackooor --save-dev A

Jan 3, 2023

Solidity starter combining foundry and hardhat because both are great and I can't live without either...

Combination Pizza Hut & Taco Bell Foundry && HardHat starter template. Motivation I like them both. With this set-up we get: Unit tests written in sol

Aug 23, 2022

Decentralized twitter using Solidity, Ethereum, hardhat, ethers, IPFS, Next.JS, TypeScript, TailwindCSS.

DWITTER: Decentralized Twitter Check out the deployed version of this app at https://dwtr.wajeshubham.in Transactions on Ethereum are slow. Therefore,

Sep 2, 2022

Hardhat plugin for integration with hethers.js

hardhat-hethers Hardhat plugin for integration with hethers.js. What This plugin brings to Hardhat the Hedera library hethers.js, which allows you to

Sep 21, 2022

Use Hardhat & Foundry in the same project

Hardhat Foundry Starter This is a solidity starter template which lets you use both, Hardhat and Foundry. Why use both the tools? Foundry has some awe

Aug 23, 2022

Build your zkp app with typescript, hardhat, circom, and snarkjs!

Zk app boilerplate Pre requisites Install rust and circom2 Getting started Clone or fork this template repository. git clone https://github.com/wanseo

Dec 20, 2022

Build your zkp app with typescript, hardhat, circom, and snarkjs!

Zk app boilerplate Pre requisites Install rust and circom2 Getting started Clone or fork this template repository. git clone https://github.com/wanseo

May 18, 2022
Owner
Huff
Huff is a low level assembly language for the Ethereum Virtual Machine
Huff
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Main Site for the Huff Language.

Huff UI A simple landing page for the Huff Language. Get Started Install yarn if you haven't already: npm i -g yarn Install dependencies and start the

Huff 7 Jul 26, 2022
A Typescript Hardhat-based template to develop evm-based smart contracts with all the tooling you need.

EVM-based Smart Contract Scaffold A Typescript Hardhat-based template to develop evm-based smart contracts with all the tooling you need. Features Use

Flair 8 Oct 24, 2022
Nodejs agent for Sidekick open-source live application debugger

Sidekick Agent NodeJS Sidekick agent Nodejs is a Nodejs library that communicate with Sidekick broker to inspect, monitor and debug your application o

Sidekick 12 Nov 8, 2022
A Front-End JavaScript Debugger

vDebugger · English | 简体中文 A Front-End JavaScript Breakpoint Debugger. Make it possible to debug your JavaScript in browser, Node.js, JavaScriptCore o

Wechat.js 6 Nov 8, 2022
A fully-fledged Hardhat project template based on TypeScript.

Fully-Fledged Hardhat Project Template Based on TypeScript Installation It is recommended to install Yarn through the npm package manager, which comes

Pascal Marco Caversaccio 75 Dec 21, 2022
Build a Full Stack Marketplace on Ethereum with React, Solidity, Hardhat, and Ethers.js

Building a Digital Marketplace on Ethereum The technologies used in this workshop are React, Next.js, Tailwind CSS, HardHat, Solidity, and Ethers. Get

Nader Dabit 114 Nov 15, 2022
A web3 starter project using Typescript, Hardhat, ethers.js and @web3-react

Starter React Typescript Ethers.js Hardhat Project This repo contains a Hardhat and React Dapp starter project. The React Dapp in the frontend dir of

ChainShot 39 Dec 31, 2022