Cover photo

Deploy hello_world with Foundry on TAIKO

  1. Install Foundry on Your Computer:

    • First, you need to get Foundry, a toolkit for smart contract development. To do this, open the command line on your computer and enter these two commands:

      • curl -L https://foundry.paradigm.xyz | bash - This command downloads the Foundry installation script.

      • foundryup - This command runs the script you just downloaded, which installs Foundry.

  2. Set Up a New Foundry Project:

    • Now, create a new directory for your smart contract project and move into it by typing:

      • forge init hello_foundry && cd hello_foundry - This creates a new folder named hello_foundry with the necessary Foundry setup files and then changes the directory to hello_foundry.

  3. Deploy Your Smart Contract:

    • You're ready to deploy your smart contract. You'll be working with a file named Counter.sol that should be in the src folder of your project. To deploy the contract, you need to replace YOUR_PRIVATE_KEY with the actual private key from your Ethereum wallet. Make sure this wallet has some testnet ETH for the deployment. Here's the command:

      • forge create src/Counter.sol:Counter --rpc-url https://rpc.katla.taiko.xyz --private-key YOUR_PRIVATE_KEY - This tells Foundry to deploy the Counter contract using the Taiko testnet.

Remember, never share your private key with anyone and be careful where you input it. Always check the commands and URLs you use for interacting with your crypto assets to prevent any security risks.

Verify Your Smart Contract with Foundry:

  • After deploying your contract, you'll want to verify it so others can see the code and confirm it's legitimate. You'll need the address of the deployed contract and the path to the contract file you used. Here's what to do:

    • Replace 0x526317252e346978869d178081dA2cd10ac8b56D with your contract's actual address.

    • Replace src/Counter.sol:Counter with the actual path and filename of your contract's code.

    • Open your terminal and run the following command with those replacements:

      • forge verify-contract 0x526317252e346978869d178081dA2cd10ac8b56D src/Counter.sol:Counter --verifier-url https://blockscoutapi.katla.taiko.xyz/api\? --verifier blockscout

      • This command sends your contract code to the specified verifier URL, which is the API for the Taiko testnet's block explorer, Blockscout.

By running this command, you submit your contract for verification. If everything is correct, your contract should soon be verified and visible on the testnet's block explorer, allowing anyone to review the contract's code.