Solidity.

帖子

分享您的知识。

0x2d00...7bfb.
Aug 15, 2023
讨论

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

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. 
  • Smart Contract
  • Solidity
0
1
分享
评论
.

答案

1
Daniel.
Aug 18 2023, 06:18

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
0
评论
.

你知道答案吗?

请登录并分享。

Solidity is an object-oriented, high-level language for implementing smart contracts. It is a curly-bracket language designed to target the Ethereum Virtual Machine (EVM).

39帖子48答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

获取声誉积分,并因帮助 Sui 社区成长而获得奖励。