From 4e853b1f2e42eb4e2490a4314941a5672b8c7b7c Mon Sep 17 00:00:00 2001 From: Penzlik Date: Wed, 20 May 2026 10:45:01 +0300 Subject: [PATCH 1/2] fix: replace Etherscan with Blockscout for contract verification on Ink Sepolia --- .../deploying-a-smart-contract/foundry.mdx | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 src/pages/build/tutorials/deploying-a-smart-contract/foundry.mdx diff --git a/src/pages/build/tutorials/deploying-a-smart-contract/foundry.mdx b/src/pages/build/tutorials/deploying-a-smart-contract/foundry.mdx new file mode 100644 index 000000000..223974ef8 --- /dev/null +++ b/src/pages/build/tutorials/deploying-a-smart-contract/foundry.mdx @@ -0,0 +1,190 @@ +import CopyableCode from "@/components/CopyableCode"; +import { TestnetDisclaimer } from "@/components/TestnetDisclaimer"; + +# Deploying a Smart Contract with Foundry + +This guide will walk you through setting up a new project using Foundry, a blazing fast toolkit for Ethereum application development written in Rust. + +## Installing Foundry + +First, you'll need to install Foundry. Run this command in your terminal: + +```bash +curl -L https://foundry.paradigm.xyz | bash +``` + +Then run: + +```bash +foundryup +``` + +This will install `forge`, `cast`, and `anvil` - the core tools of Foundry. You can also use `foundryup` to update the tools to the latest version. + +## Creating a New Project + +To create a new project, navigate to the directory where you want to create your project and use the `forge init` command: + +```bash +forge init my_project +cd my_project +``` + +This will create a new directory with the following structure: + +``` +my_project/ +├── lib/ +├── src/ +│ └── Counter.sol +├── test/ +│ └── Counter.t.sol +├── script/ +├── .gitignore +└── foundry.toml +``` + +## Writing Your First Contract + +Remove the default Counter example contract: + +```bash +rm -rf src/Counter.sol script/Counter.s.sol test/Counter.t.sol +``` + +Create a new contract and put it in the file : + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; +contract InkContract { + string public greeting = "Hello, Ink!"; + + function setGreeting(string memory _greeting) public { + greeting = _greeting; + } +} +``` + +Create the tests for this contract in the file : + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; + +import {Test} from "forge-std/Test.sol"; +import {InkContract} from "../src/InkContract.sol"; + +contract InkContractTest is Test { + InkContract public ink; + + function setUp() public { + ink = new InkContract(); + } + + function test_DefaultGreeting() public view { + assertEq(ink.greeting(), "Hello, Ink!"); + } + + function test_SetGreeting() public { + string memory newGreeting = "New greeting!"; + ink.setGreeting(newGreeting); + assertEq(ink.greeting(), newGreeting); + } + + function testFuzz_SetGreeting(string memory randomGreeting) public { + ink.setGreeting(randomGreeting); + assertEq(ink.greeting(), randomGreeting); + } +} +``` + +## Building and Testing + +Build your project: + +```bash +forge build +``` + +Run tests: + +```bash +forge test +``` + +## Deployment + +1. First, create a file in your project root: + +```env +PRIVATE_KEY=your_private_key_here +RPC_URL=https://rpc-gel-sepolia.inkonchain.com/ +BLOCKSCOUT_API_KEY=your_blockscout_api_key_here +``` + +2. Create a deployment script in : + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.19; +import "forge-std/Script.sol"; +import "../src/InkContract.sol"; + +contract DeployScript is Script { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + + vm.startBroadcast(deployerPrivateKey); + + new InkContract(); + + vm.stopBroadcast(); + } +} +``` + +3. Deploy your contract: + +```bash +# Load environment variables +source .env + +# Deploy to InkSepolia Testnet +forge script script/Deploy.s.sol:DeployScript --rpc-url $RPC_URL --broadcast --verify +``` + +## Verifying Your Contract + +If you want to verify your contract on Blockscout: + +```bash +forge verify-contract src/InkContract.sol:InkContract \ + --chain-id 763373 \ + --verifier blockscout \ + --verifier-url https://explorer-sepolia.inkonchain.com/api \ + --verifier-api-key $BLOCKSCOUT_API_KEY +``` + +## Additional Configuration + +You can customize your Foundry setup in `foundry.toml`: + +```toml +[profile.default] +src = "src" +out = "out" +libs = ["lib"] +solc = "0.8.19" +optimizer = true +optimizer_runs = 200 + +[rpc_endpoints] +inksepolia = "${INKSEPOLIA_RPC_URL}" +``` + +## Next Steps + +- Check out [Get Foundry Book](https://book.getfoundry.sh/) for more information on Foundry. + + From 76eadde47723342c7bb9983e3ce708e375fe0c95 Mon Sep 17 00:00:00 2001 From: Penzlik Date: Wed, 20 May 2026 10:49:14 +0300 Subject: [PATCH 2/2] fix: use Blockscout verifier flags for Ink Sepolia contract verification - Replaced --etherscan-api-key with Blockscout flags - Added section 'Verify Contract Source on Blockscout' - Closes #609 --- docs/base-chain/quickstart/deploy-on-base.mdx | 20 ++ .../deploying-a-smart-contract/foundry.mdx | 190 ------------------ 2 files changed, 20 insertions(+), 190 deletions(-) delete mode 100644 src/pages/build/tutorials/deploying-a-smart-contract/foundry.mdx diff --git a/docs/base-chain/quickstart/deploy-on-base.mdx b/docs/base-chain/quickstart/deploy-on-base.mdx index af591acd6..2cc40b61c 100644 --- a/docs/base-chain/quickstart/deploy-on-base.mdx +++ b/docs/base-chain/quickstart/deploy-on-base.mdx @@ -165,6 +165,26 @@ This will return the initial value of the Counter contract's `number` storage va **Congratulations! You've deployed your smart contracts to Base Sepolia!** +### Verify Contract Source on Blockscout + +To make your contract source code publicly readable on [Blockscout](https://base-sepolia.blockscout.com/): + +1. Run the following command: + +```bash +forge verify-contract $COUNTER_CONTRACT_ADDRESS \ + src/Counter.sol:Counter \ + --verifier blockscout \ + --verifier-url https://base-sepolia.blockscout.com/api/ \ + --chain-id 84532 +``` + + +Blockscout does not require a real API key — you can pass any non-empty string or omit `--etherscan-api-key` entirely when using `--verifier blockscout`. + + +2. Visit [Blockscout Base Sepolia](https://base-sepolia.blockscout.com/) and search your contract address to confirm the ✅ **Verified** badge. + ## Next Steps - Use [wagmi](https://wagmi.sh) or [viem](https://viem.sh) to connect your frontend to your contracts. diff --git a/src/pages/build/tutorials/deploying-a-smart-contract/foundry.mdx b/src/pages/build/tutorials/deploying-a-smart-contract/foundry.mdx deleted file mode 100644 index 223974ef8..000000000 --- a/src/pages/build/tutorials/deploying-a-smart-contract/foundry.mdx +++ /dev/null @@ -1,190 +0,0 @@ -import CopyableCode from "@/components/CopyableCode"; -import { TestnetDisclaimer } from "@/components/TestnetDisclaimer"; - -# Deploying a Smart Contract with Foundry - -This guide will walk you through setting up a new project using Foundry, a blazing fast toolkit for Ethereum application development written in Rust. - -## Installing Foundry - -First, you'll need to install Foundry. Run this command in your terminal: - -```bash -curl -L https://foundry.paradigm.xyz | bash -``` - -Then run: - -```bash -foundryup -``` - -This will install `forge`, `cast`, and `anvil` - the core tools of Foundry. You can also use `foundryup` to update the tools to the latest version. - -## Creating a New Project - -To create a new project, navigate to the directory where you want to create your project and use the `forge init` command: - -```bash -forge init my_project -cd my_project -``` - -This will create a new directory with the following structure: - -``` -my_project/ -├── lib/ -├── src/ -│ └── Counter.sol -├── test/ -│ └── Counter.t.sol -├── script/ -├── .gitignore -└── foundry.toml -``` - -## Writing Your First Contract - -Remove the default Counter example contract: - -```bash -rm -rf src/Counter.sol script/Counter.s.sol test/Counter.t.sol -``` - -Create a new contract and put it in the file : - -```solidity -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; -contract InkContract { - string public greeting = "Hello, Ink!"; - - function setGreeting(string memory _greeting) public { - greeting = _greeting; - } -} -``` - -Create the tests for this contract in the file : - -```solidity -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; - -import {Test} from "forge-std/Test.sol"; -import {InkContract} from "../src/InkContract.sol"; - -contract InkContractTest is Test { - InkContract public ink; - - function setUp() public { - ink = new InkContract(); - } - - function test_DefaultGreeting() public view { - assertEq(ink.greeting(), "Hello, Ink!"); - } - - function test_SetGreeting() public { - string memory newGreeting = "New greeting!"; - ink.setGreeting(newGreeting); - assertEq(ink.greeting(), newGreeting); - } - - function testFuzz_SetGreeting(string memory randomGreeting) public { - ink.setGreeting(randomGreeting); - assertEq(ink.greeting(), randomGreeting); - } -} -``` - -## Building and Testing - -Build your project: - -```bash -forge build -``` - -Run tests: - -```bash -forge test -``` - -## Deployment - -1. First, create a file in your project root: - -```env -PRIVATE_KEY=your_private_key_here -RPC_URL=https://rpc-gel-sepolia.inkonchain.com/ -BLOCKSCOUT_API_KEY=your_blockscout_api_key_here -``` - -2. Create a deployment script in : - -```solidity -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; -import "forge-std/Script.sol"; -import "../src/InkContract.sol"; - -contract DeployScript is Script { - function run() external { - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - - vm.startBroadcast(deployerPrivateKey); - - new InkContract(); - - vm.stopBroadcast(); - } -} -``` - -3. Deploy your contract: - -```bash -# Load environment variables -source .env - -# Deploy to InkSepolia Testnet -forge script script/Deploy.s.sol:DeployScript --rpc-url $RPC_URL --broadcast --verify -``` - -## Verifying Your Contract - -If you want to verify your contract on Blockscout: - -```bash -forge verify-contract src/InkContract.sol:InkContract \ - --chain-id 763373 \ - --verifier blockscout \ - --verifier-url https://explorer-sepolia.inkonchain.com/api \ - --verifier-api-key $BLOCKSCOUT_API_KEY -``` - -## Additional Configuration - -You can customize your Foundry setup in `foundry.toml`: - -```toml -[profile.default] -src = "src" -out = "out" -libs = ["lib"] -solc = "0.8.19" -optimizer = true -optimizer_runs = 200 - -[rpc_endpoints] -inksepolia = "${INKSEPOLIA_RPC_URL}" -``` - -## Next Steps - -- Check out [Get Foundry Book](https://book.getfoundry.sh/) for more information on Foundry. - -