2

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 setup. 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!

1
  • 1
    What button are you pressing to get the error You have not set a script to run. Set it with @custom:dev-run-script NatSpec tag. Commented Feb 27 at 13:53

1 Answer 1

3
+50

First of all I'd like to point out some clarifications:

  • I assume that you are clicking on the "Compile and run script" button (because that's the only button that shows the same "script not set ... blah blah blah message when I click on it).
  • The only case that gives the same "running file_path ... file_path does not exist." error is when I specify @custom:dev-run-script as a string file_path

remix_view_number_1

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.

Oh, no no! You shouldn't target versions that are incompatible with the ones specified in your *.sol files! The compiler version is not the culprit here at all.


If you intend to run scripts/deploy_with_ethers.ts to deploy the Ballot contract from 3_Ballot.sol, you need to first make some adaptations to the script, because currently the script can only deploy 1_Storage.sol.

You can see the warning at the top of the script file:

remix_2


Here's the script that you can use to deploy 3_Ballot.sol:

// This script can be used to deploy the "Ballot" contract using ethers.js library.
// Please make sure to compile "./contracts/3_Ballot.sol" file before running this script.
// And use Right click -> "Run" from context menu of the file to run the script. Shortcut: Ctrl+Shift+S

import { deploy } from './ethers-lib'

(async () => {
  try {
    const proposalNames = [/* list your proposals here as you wish... */];
    const result = await deploy('Ballot', [proposalNames])
    console.log(`address: ${result.address}`)
  } catch (e) {
    console.log(e.message)
  }
})()

And then your NatSpec for the Ballot should be:

/** 
 * @title Ballot
 * @dev Implements voting process along with vote delegation
 * @custom:dev-run-script ./scripts/deploy_with_ethers.ts
*/

...Voilà!

remix_3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.