Error: contract source info format must be `<path>:<contractname>` or `<contractname>` user@user:~/src$ forge script script/lib/forge-std/DeploySimpleStorage.s.sol``` I found the lib/forge-std library was missing from my installation as I could not find it by exploring on top right.So subsequently installed it by creating Lib folder and then pasted forge-std inside it. I guess wrong path of folder could be the cause of this error. Please help how to set it correctly. I tried resolving it by copying the DeploySimpleStorage.s.sol and SimpleStorage.sol inside various folders and subfolders but could not make it work. Please help me make it work. "> Error: contract source info format must be `<path>:<contractname>` or `<contractname>` user@user:~/src$ forge script script/lib/forge-std/DeploySimpleStorage.s.sol``` I found the lib/forge-std library was missing from my installation as I could not find it by exploring on top right.So subsequently installed it by creating Lib folder and then pasted forge-std inside it. I guess wrong path of folder could be the cause of this error. Please help how to set it correctly. I tried resolving it by copying the DeploySimpleStorage.s.sol and SimpleStorage.sol inside various folders and subfolders but could not make it work. Please help me make it work. "> Error: contract source info format must be `<path>:<contractname>` or `<contractname>` user@user:~/src$ forge script script/lib/forge-std/DeploySimpleStorage.s.sol``` I found the lib/forge-std library was missing from my installation as I could not find it by exploring on top right.So subsequently installed it by creating Lib folder and then pasted forge-std inside it. I guess wrong path of folder could be the cause of this error. Please help how to set it correctly. I tried resolving it by copying the DeploySimpleStorage.s.sol and SimpleStorage.sol inside various folders and subfolders but could not make it work. Please help me make it work. ">

running a script command in VS code for deploying a solidity smart contract on Foundry

Discussion

I am getting this error while running a solidity script inside VS code for deploying a solidity smart contract "SimpleStorage" on Foundry.

Error: 
contract source info format must be `<path>:<contractname>` or `<contractname>`
user@user:~/src$ forge script script/lib/forge-std/DeploySimpleStorage.s.sol```

I found the lib/forge-std library was missing from my installation as I could not find it by exploring on top right.So subsequently installed it by creating Lib folder and then pasted forge-std inside it. I guess wrong path of folder could be the cause of this error. Please help how to set it correctly. 

I tried resolving it by copying the DeploySimpleStorage.s.sol and SimpleStorage.sol inside various folders and subfolders but could not make it work.  Please help me make it work. 

Answers 1

I think it wants not just file name but also the name of your script contract.

See example here: https://book.getfoundry.sh/tutorials/solidity-scripting

File is NFT.s.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import "../src/NFT.sol";

contract MyScript is Script {
    function run() external {
        uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
        vm.startBroadcast(deployerPrivateKey);

        NFT nft = new NFT("NFT_tutorial", "TUT", "baseUri");

        vm.stopBroadcast();
    }
}

And the command to run that script is following:

# To load the variables in the .env file
source .env

# To deploy and verify our contract
forge script script/NFT.s.sol:MyScript --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv