Cyfrin / foundry-full-course-cu

GNU General Public License v3.0
2.88k stars 671 forks source link

Error with running "forge script" #1050

Closed AnthonyHarvey8867 closed 5 months ago

AnthonyHarvey8867 commented 8 months ago

Hey guys, I'm having difficulties with the last part of video 1; deploying "SimpleStorage.sol" in foundry; where there is a script to deploy the smart contract. here is the script from the first video of the course:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

// import {Script} from "../lib/forge-std/src/Script.sol";
import {Script} from "forge-std/Script.sol";
import {SimpleStorage} from "../src/SimpleStorage.sol";

contract DeploySimpleStorage is Script {
    function run() external returns (SimpleStorage) {
        vm.startBroadcast();
        SimpleStorage simpleStorage = new SimpleStorage();
        vm.stopBroadcast();
        return simpleStorage;
    }
}

then when I run "forge script scr/SimpleStorage.sol" in the command line. I get the following error:

[⠊] Compiling...
[⠃] Compiling 22 files with 0.8.21
[⠰] Solc 0.8.21 finished in 4.80s
Compiler run successful!
Error: 
Function `run()` is not implemented in your script.

I have tried the command with other test files but the issue still persists!

anyone has any ideas as to why it keeps referring to "run() " function while it has been defined within the script!

gKrithick commented 8 months ago

isn't the command for running the script file should be forge script src/SimpleStorage.s.sol ??? or if you've name your folder and file to be scr and SimpleStorage respectively you shouldn't face any problem since I don't see any problem with the code!

lpetroulakis commented 7 months ago

as mentioned above, the command you should probably use is the following

forge script script/DeploySimpleStorage.s.sol
GhislainTselone commented 7 months ago

Hello buddy ! Here is the right script to deploy the contract on the local chain :

forge script script/DeploySimpleStorage.s.sol --rpc-url $RPC_URL    --broadcast             --private-key $PRIVATE_KEY 

Hope it helps :)

musaCODEzz commented 7 months ago

how do i get the fork url that I am constantly getting requested to have

KAravind2005 commented 6 months ago

The file name has to be SimpleStorage.s.sol