here are steps on how you can deploy your smart contracts using foundry with scripts
N.B : you must have foundry installed in your local machine
- Run Anvil : command for running anvil is - "anvil"
- Copy the localhost and paste in command below after --rpc-url
forge script script/DeployContract.s.sol --rpc-url http://127.0.0.1:8545 --broadcast --private-key {PRIVATE_KEY}
our script file will be something like this:
`// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity ^0.8.18;
import {Script} from "forge-std/Script.sol";
import {Counter} from "../src/Counter.sol";
contract DeployCounter is Script {
function run() external returns (Counter) {
vm.startBroadcast();
Counter counter = new Counter();
vm.stopBroadcast();
return counter;
}
}`
Your smart contract should now be deployed to the onchain link
Top comments (0)