forge create
command. Here’s how to deploy a Counter.sol contract:
forge create
: The command to deploy a contract--rpc-url
: Your network’s RPC URL--private-key
: Your wallet’s private key (never share this!)src/Counter.sol:Counter
: The path to your contract file and the contract name after the colon
Importance of Dry Runs
This will generate a build version of the contract. This is always good to run before actually deploying onto blockchain in order to see what if command has bugs but more importantly save money. If you deployment, you will still pay gas fees.Real Run
To put the transaction on Testnet, we will need to add the--broadcast
flag at the end of the function.
Deployer
-> Your public addressDeployed
to -> Deployed contract addressTransaction hash
-> Transaction that we just signed above ^
Interacting with the Smart Contract
It doesn’t cost money to view the state of the blockchain. Notice that viewing the blockchain we use call.Changing the state on the blockchain requires paying gas. Viewing does not,
hence why we are not signing with our private key