### Install viem with npm Source: https://docs.inkonchain.com/build/onchain-clients Install the viem library using npm. Required before using the Public Client example. ```bash npm install viem ``` -------------------------------- ### Install viem with yarn Source: https://docs.inkonchain.com/build/onchain-clients Alternative installation of viem using yarn. Required before using the Public Client example. ```bash yarn add viem ``` -------------------------------- ### Install Foundry with curl and foundryup Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/foundry Install Foundry by running the installer script, then run foundryup to install forge, cast, and anvil. Use foundryup again to update the tools to the latest version. ```bash curl -L https://foundry.paradigm.xyz | bash ``` ```bash foundryup ``` -------------------------------- ### Install ethers.js v6 with npm Source: https://docs.inkonchain.com/build/onchain-clients Install ethers.js v6 using npm. Required before using the JsonRpcProvider example. ```bash npm install ethers@6 ``` -------------------------------- ### Install @krakenfx/verify Source: https://docs.inkonchain.com/build/verify Install the @krakenfx/verify package using npm, yarn, or pnpm. ```bash # Using npm npm install @krakenfx/verify # Using yarn yarn add @krakenfx/verify # Using pnpm pnpm add @krakenfx/verify ``` -------------------------------- ### Initialize environment files Source: https://docs.inkonchain.com/build/tutorials/deploying-a-superchainerc20 Sets up environment files required for the project. Run after installing dependencies. ```bash pnpm init:env ``` -------------------------------- ### Start local Hardhat node Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Launches a local Ethereum network for development. ```bash npx hardhat node ``` -------------------------------- ### Install dependencies with pnpm Source: https://docs.inkonchain.com/build/tutorials/deploying-a-superchainerc20 Installs project dependencies using pnpm. Run after cloning the repository. ```bash pnpm i ``` -------------------------------- ### Install ethers.js v6 with yarn Source: https://docs.inkonchain.com/build/onchain-clients Alternative installation of ethers.js v6 using yarn. Required before using the JsonRpcProvider example. ```bash yarn add ethers@6 ``` -------------------------------- ### Start the development environment Source: https://docs.inkonchain.com/build/tutorials/deploying-a-superchainerc20 Starts the local development environment, which includes anvil. Run after initializing environment files. ```bash pnpm dev ``` -------------------------------- ### Install Hardhat and toolbox Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Installs Hardhat and the Hardhat Toolbox as development dependencies. ```bash npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox ``` -------------------------------- ### Install @inkonchain/ink-kit Source: https://docs.inkonchain.com/build/ink-kit Install the Ink Kit package using npm or pnpm. The package is archived and no longer maintained. ```bash npm install @inkonchain/ink-kit # or pnpm install @inkonchain/ink-kit ``` -------------------------------- ### Clone the superchainerc20-starter repository Source: https://docs.inkonchain.com/build/tutorials/deploying-a-superchainerc20 Clones the starter repository and changes into its directory. Required before installing dependencies. ```bash git clone git@github.com:ethereum-optimism/superchainerc20-starter.git cd superchainerc20-starter ``` -------------------------------- ### Check Node.js version Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Run this command to verify Node.js is installed (version 20 or later is required). ```bash node --version ``` -------------------------------- ### Open Hardhat console on Ink Sepolia Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Starts an interactive console connected to the inksepolia network. ```bash npx hardhat console --network inksepolia ``` -------------------------------- ### Check verification with VerifyClient (ESM/TypeScript) Source: https://docs.inkonchain.com/build/verify ESM/TypeScript example checking if an address is verified using VerifyClient. ```typescript // ES Modules / TypeScript import { VerifyClient } from "@krakenfx/verify"; const verifyClient = new VerifyClient(); const yourAddress = "0x2193981f2d65149644C039c9071f2bE8b5938F0B"; // Check if an address is verified const isVerified = await verifyClient.isAddressVerified(yourAddress); console.log(`Result: ${isVerified ? "✅ Verified" : "❌ Not verified"}`); ``` -------------------------------- ### Configure foundry.toml for Ink Sepolia Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/foundry Customize the Foundry setup in foundry.toml with the default profile settings and an RPC endpoint for Ink Sepolia using the INKSEPOLIA_RPC_URL environment variable. ```toml [profile.default] src = "src" out = "out" libs = ["lib"] solc = "0.8.19" optimizer = true optimizer_runs = 200 [rpc_endpoints] inksepolia = "${INKSEPOLIA_RPC_URL}" ``` -------------------------------- ### Create InkContract tests in test/InkContract.t.sol Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/foundry Create tests for InkContract in test/InkContract.t.sol. It includes a setUp function, a default greeting test, a setGreeting test, and a fuzz test for setGreeting. ```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); } } ``` -------------------------------- ### Create and initialize a new Hardhat project directory Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Creates a new directory, moves into it, and initializes a Node.js project with npm. ```bash mkdir my-hardhat-project cd my-hardhat-project npm init -y ``` -------------------------------- ### Initialize a new Hardhat project Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Runs the Hardhat initialization wizard. Choose 'Create a JavaScript project' when prompted. ```bash npx hardhat init ``` -------------------------------- ### Initialize a Foundry project with forge init Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/foundry Create a new Foundry project with forge init and change into the project directory. The output shows the default project structure, including src/Counter.sol, test/Counter.t.sol, and foundry.toml. ```bash forge init my_project cd my_project ``` ```text my_project/ ├── lib/ ├── src/ │ └── Counter.sol ├── test/ │ └── Counter.t.sol ├── script/ ├── .gitignore └── foundry.toml ``` -------------------------------- ### Build and test with forge build and forge test Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/foundry Build the project with forge build, then run the test suite with forge test. ```bash forge build ``` ```bash forge test ``` -------------------------------- ### Deploy the token Source: https://docs.inkonchain.com/build/tutorials/deploying-a-superchainerc20 Deploys the SuperchainERC20 token using the configured settings. Run after setting up the private key. ```bash pnpm contracts:deploy:token ``` -------------------------------- ### Check verification with VerifyClient (CommonJS) Source: https://docs.inkonchain.com/build/verify CommonJS example checking if an address is verified using VerifyClient. ```javascript // CommonJS const { VerifyClient } = require("@krakenfx/verify"); const verifyClient = new VerifyClient(); const yourAddress = "0x2193981f2d65149644C039c9071f2bE8b5938F0B"; // Check if an address is verified async function checkVerification() { const isVerified = await verifyClient.isAddressVerified(yourAddress); console.log(`Result: ${isVerified ? "✅ Verified" : "❌ Not verified"}`); } checkVerification(); ``` -------------------------------- ### Set up deployer private key Source: https://docs.inkonchain.com/build/tutorials/deploying-a-superchainerc20 Writes the deployer private key to packages/contracts/.env. Never share or commit the private key, and ensure the wallet has enough funds for deployment. ```bash echo 'DEPLOYER_PRIVATE_KEY=' > packages/contracts/.env ``` -------------------------------- ### Update RPC URLs Source: https://docs.inkonchain.com/build/tutorials/deploying-a-superchainerc20 Updates the RPC URLs in the project configuration. Run after starting the development environment. ```bash pnpm contracts:update:rpcs ``` -------------------------------- ### Remove default Counter contract files Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/foundry Remove the default Counter example contract files before adding your own contract. ```bash rm -rf src/Counter.sol script/Counter.s.sol test/Counter.t.sol ``` -------------------------------- ### InkContract.sol - Solidity contract for Remix deployment Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/remix Create this file in Remix's File Explorer to define the contract used throughout the tutorial. It stores a public string greeting initialized to "Hello, Ink!" and provides a setGreeting function to update it. The pragma specifies Solidity version ^0.8.19, which must match the compiler version selected in Remix. ```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; } } ``` -------------------------------- ### Override CSS variables for custom theme Source: https://docs.inkonchain.com/build/ink-kit Create a custom theme by overriding CSS variables in the :root selector. The example shows overriding --ink-button-primary. ```css :root { --ink-button-primary: rgb(10, 55, 10); ... } ``` -------------------------------- ### Environment variables for Ink Sepolia Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Create a .env file with your private key, Ink Sepolia RPC URL, and Blockscout API key. ```bash PRIVATE_KEY=your_private_key_here INK_SEPOLIA_URL=https://rpc-gel-sepolia.inkonchain.com/ BLOCKSCOUT_API_KEY=your_blockscout_api_key_here ``` -------------------------------- ### Instantiate Public Client for Ink Sepolia Source: https://docs.inkonchain.com/build/onchain-clients Creates a viem Public Client configured for the Ink Sepolia testnet using the built-in inkSepolia chain definition and HTTP transport. ```javascript import { createPublicClient, http } from 'viem' import { inkSepolia } from 'viem/chains' const client = createPublicClient({ chain: inkSepolia, transport: http(), }) ``` -------------------------------- ### Run tests Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Executes the test suite. ```bash npx hardhat test ``` -------------------------------- ### Get next nonce with eth_getTransactionCount Source: https://docs.inkonchain.com/general/support/troubleshooting Use this command to retrieve the next valid nonce for your wallet address on the Ink network. Replace YOUR_ADDRESS with your actual address. The output is the nonce value in decimal, which you should use for a recovery transaction. ```bash curl -s -X POST -H "Content-Type: application/json" --data '{ "jsonrpc":"2.0", "method":"eth_getTransactionCount", "params":["YOUR_ADDRESS", "latest"], "id":1 }' https://rpc-gel.inkonchain.com | python3 -c "import sys, json; print(int(json.load(sys.stdin)['result'], 16))" ``` -------------------------------- ### Configure deployment settings in deploy-config.toml Source: https://docs.inkonchain.com/build/tutorials/deploying-a-superchainerc20 Creates or updates the deployment configuration file at packages/contracts/configs/deploy-config.toml. Includes the deploy salt, chains, and token details such as owner address, name, symbol, and decimals. ```toml [deploy_config] salt = "ethers phoenix" chains = ["sepolia/ink"] [token] owner_address = "" # Your wallet address name = "" # The name of your token symbol = "" # Your token's symbol (e.g., "OPT") decimals = 18 # Number of decimal places (18 is standard) ``` -------------------------------- ### Deploy to Ink Sepolia Source: https://docs.inkonchain.com/build/tutorials/deploying-a-smart-contract/hardhat Runs the deployment script on the inksepolia network. ```bash npx hardhat run scripts/deploy.js --network inksepolia ```