npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yield-protocol/hardhat-dapptools

v0.1.0

Published

Hardhat dapptools integration

Downloads

7

Readme

hardhat-dapptools

Run all dapptools goodies (hevm exec, hevm symbolic, seth send, etc) on hardhat-deployed contracts

What

Ever struggled to understand why your transaction reverts? dapptools make this (and tons of other flows) easy. To get the most out of it, you need sourcemaps (unless you speak and breath EVM assembly).

This plugin does precisely that - takes your hardhat project and generates a sourcemap file that's compatible with dapptools

Installation

npm install hardhat-dapptools

Import the plugin in your hardhat.config.ts:

import "hardhat-dapptools"

Tasks

  • dapp-export: export sourcemap file to $(PROJECT_ROOT)/cache/dapp/combined.solc.json bbb

  • dapp-link If your project uses libraries, you need to link them before the sourcemap becomes useful Syntaxis similar to DAPP_LIBRARIES is used: dapp-link libA:0x3ffb52852Fb8F06f74775bFd1a669d585f89cd77 libB:0x6464F2cAd1e071e05F38562C38D94d8Cc49B4f99

Usage

Sample project can be found here. Imagine you have it deployed locally (to hardhat node or similar) at 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512, and the library is deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3

The contract ABI is simple:

    function computeGreet(string memory input) public returns(string memory);

    function greet() external returns (string memory);

Let's try and call greet() and see why it reverts:

~/src/hardhat-dapps ❯❯❯ hevm exec --calldata `seth calldata "greet()(string)"` --address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --trace --rpc http://127.0.0.1:8545 --gas 1000000
log1(0x597685b0c880083aeaf7da2ab06d483281f77abbefe5993feeb0dbc60593dc44, 0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000056772656574000000000000000000000000000000000000000000000000000000) <no source map>
log1(0x597685b0c880083aeaf7da2ab06d483281f77abbefe5993feeb0dbc60593dc44, 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c636f6d7075746547726565740000000000000000000000000000000000000000) <no source map>
delegatecall 0x5FbDB2315678afecb367f032d93F642f64180aa3::0x1a43c338 <no source map>
 └╴← 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000e68656c6c6f2066726f6d206c6962000000000000000000000000000000000000
log1(0x9621a8d19ea0100d87d35d5c9f74911c53dd3a9879a4977f3c84399d5f7572c7, 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c636f6d7075746547726565740000000000000000000000000000000000000000) <no source map>
0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001e48656c6c6f2c2048617264686174212e68656c6c6f2066726f6d206c69620000

Sad. Now let's export and link the sourcemap:

~/src/hardhat-dapps ❯❯❯ npx hardhat dapp-export
Compiling 2 files with 0.8.4
[HARDHAT-DAPP]	/Users/owleksiy/src/hardhat-dapps/cache/dapp/combined.solc.json
Generating typings for: 2 artifacts in dir: typechain for target: ethers-v5
Successfully generated 7 typings!
Compilation finished successfully

~/src/hardhat-dapps ❯❯❯ npx hardhat dapp-link GreeterLib:0x5FbDB2315678afecb367f032d93F642f64180aa3
Linked GreeterLib: __$2cf91d1f08d1450ca29d91986067042362$__ -> 5FbDB2315678afecb367f032d93F642f64180aa3
Linked GreeterLib: __$2cf91d1f08d1450ca29d91986067042362$__ -> 5FbDB2315678afecb367f032d93F642f64180aa3
[HARDHAT-DAPP] linked:  /Users/owleksiy/src/hardhat-dapps/cache/dapp/combined.solc.json

The output file (cache/dapp/combined.solc.json) can be passed to hevm:

~/src/hardhat-dapps ❯❯❯ hevm exec --calldata `seth calldata "greet()(string)"` --address 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 --trace --rpc http://127.0.0.1:8545 --gas 1000000 --json-file /Users/owleksiy/src/hardhat-dapps/cache/dapp/combined.solc.json
FnEnter("greet") (contracts/Greeter.sol:24)
FnEnter("computeGreet") (contracts/Greeter.sol:17)
delegatecall 0x5FbDB2315678afecb367f032d93F642f64180aa3::compute() (contracts/Greeter.sol:18)
 └╴← ("hello from lib")
FnExit("computeGreet") (contracts/Greeter.sol:19)
0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001e48656c6c6f2c2048617264686174212e68656c6c6f2066726f6d206c69620000

Looks much better