Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npx hardhat run support #28

Open
lomonoshka opened this issue Feb 18, 2023 · 3 comments
Open

npx hardhat run support #28

lomonoshka opened this issue Feb 18, 2023 · 3 comments

Comments

@lomonoshka
Copy link

lomonoshka commented Feb 18, 2023

Hey, thanks for the great plugin!
Would it be possible to add support of --trace to hardhat run command?

@zemse
Copy link
Owner

zemse commented Feb 20, 2023

I'll explore if this can be supported. But for now this workaround can be used:

import hre from 'hardhat'; 
import { wrapHardhatProvider } from "hardhat-tracer/dist/src/wrapper";

wrapHardhatProvider(hre);
hre.tracer.enabled = true;
hre.tracer.verbosity = 3; // prints all txs, use 1 if you need only failed printings

async function main() {
  ...
}

@AlexBlack772
Copy link

AlexBlack772 commented Feb 28, 2023

I need this feature too, It would be very usefull.

Maybe this is a limitation of hre/ethers but provided workaround show traces only for successfull calls. If call ended up with a revert, no traces are shown. but with npx hardhat trace --hash all traces are shown

as a quick and dirty workaraund I use

`
try {
let tx = await signer.sendTransaction(params);
...
} catch (err) {
console.log(err.data.message,err.data.txHash);

    printDebugTraceOrLogs(err.data.txHash,{
        artifacts: hre.artifacts,
        tracerEnv: hre.tracer,
        provider: hre.network.provider,
        nameTags: {},
      });
}

`

@zemse
Copy link
Owner

zemse commented Feb 28, 2023

Maybe this is a limitation of hre/ethers but provided workaround show traces only for successfull calls

Yeah this was the case in V1 because it relied on debug_traceTransaction. But in v2 it hijacks the VM to get the execution info and now you do not need to do this. --trace would print all successful and failed while --traceError would only print the failed transactions or calls for you. To use v2 you can just install latest version npm i hardhat-tracer@latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants