ethereum / remix-project

Remix is a browser-based compiler and IDE that enables users to build Ethereum contracts with Solidity language and to debug transactions.
https://remix-ide.readthedocs.io
MIT License
2.4k stars 910 forks source link

Error: You have not set a script to run. Set it with @custom:dev-run-script NatSpec tag. #4545

Open jf11235 opened 6 months ago

jf11235 commented 6 months ago

I'm taking a course and trying to run a file called 3_Ballot.sol. I'm getting this error:

"You have not set a script to run. Set it with @custom:dev-run-script NatSpec tag."

I've been researching for hours, and I'm trying to run this tag at the beginning, with no luck:

/* @title Ballot @dev Contract for conducting a ballot /

I've also tried this: /* @title ContractName @dev ContractDescription @custom:dev-run-script scripts/deploy_with_ethers.ts / I'm running pragma solidity ^0.4.17, with the compiler set accordingly. I've tried 0.8.24, 0.7.0, and a few others.

A few times, for no apparent reason, I got a different error saying: "running file_path ... file_path does not exist."

There doesn't seem to be a place for me to set the file path in the remix ide, or if there is, it eludes me.

I'm in the default remix set up. The file I'm working on is in the contracts directory. I was working on the same file last week with no issues.

Any help would be very much appreciated!

Aniket-Engg commented 6 months ago

Hello @jf11235 , You need to define path for a script here @Custom:dev-run-script scripts/deploy_with_ethers.ts on the place of scripts/deploy_with_ethers.ts . Script added with that natspec tag will be running soon after compilation.

It may not work for older compiler versions as @custom natspec tag was not there initially.

For more: https://remix-ide.readthedocs.io/en/latest/running_js_scripts.html#compile-a-contract-and-run-a-script-on-the-fly

jf11235 commented 6 months ago

Hi Aniket,

Thanks for your reply. Can you please clarify? I'm having trouble following your comments.

The documentation says to run this, which I mentioned I already tried with no success:

/**

I also tried:

/**

contract Lottery{ address public manager;

function Lottery() public{
    manager = msg.sender;
}

}

@Custom:dev-run-script scripts/deploy_with_ethers.ts pragma solidity ^0.4.17;

contract Lottery{ address public manager;

function Lottery() public{
    manager = msg.sender;
}

}

And I've also tried this: /**

contract Lottery{ address public manager;

function Lottery() public{
    manager = msg.sender;
}

}

I've also tried variations such as: /**

contract Lottery{ address public manager;

function Lottery() public{
    manager = msg.sender;
}

}

All of these yield the same error. Can you please clarify what I need to do to run the contract in Remix?

Thanks! Josh

Aniket-Engg commented 6 months ago

Try with latest compiler version as pragma

jf11235 commented 6 months ago

Hi Aniket, Yes as I mentioned in my original post, I tried the latest version and several others with the same error. I also tried modifying the deploy_with_ether.ts with my contract name rather than 'Storage', however everything yields the same error. Any other suggestions?

Aniket-Engg commented 6 months ago

You need to mention a js or ts script path with @Custom:dev-run-script tag not a contract file. Please go through the documentation link shared above.

Also, please join our discord for such communications: https://discord.gg/mh9hFCKkEq

jf11235 commented 6 months ago

Hello Aniket,

Thanks for your comment. Yes, I read the documentation. As I said above:


The documentation says to run this, which I mentioned I already tried with no success:

/**

@title ContractName @dev ContractDescription @Custom:dev-run-script scripts/deploy_with_ethers.ts */ contract ContractName {} I also tried:

/**

@title ContractName @dev ContractDescription @Custom:dev-run-script scripts/deploy_with_ethers.ts */

As I mentioned, I tried this, as well as the many variations I listed in my posts, with no success. If I am not understanding something I would appreciate a clarification. If this looks correct to you (as it seems to be consistent with the documentation) I would assume there is a bug in Remix. Please advise.