diff --git a/docs/examples/build-a-minimal-dapp.md b/docs/examples/build-a-minimal-dapp.md new file mode 100644 index 00000000..d9da9761 --- /dev/null +++ b/docs/examples/build-a-minimal-dapp.md @@ -0,0 +1,139 @@ +# Building a Minimal dApp on Base + +This guide walks through creating a very small decentralized application deployed on the **Base Sepolia Testnet**. +It includes a Solidity contract, deployment script and a minimal HTML/JS frontend. + +--- + +## 1. Prerequisites + +- Node.js 18+ +- npm or yarn +- Foundry or Hardhat +- A wallet (Metamask, Rabby, etc.) +- At least 0.001 BASE Sepolia testnet ETH + (from https://faucet.circle.com or https://www.alchemy.com/faucets/base-sepolia) + +--- + +## 2. Create a Basic Solidity Contract + +Create a file: + +`contracts/Counter.sol` + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.21; + +contract Counter { + uint256 public count; + + function increment() external { + count += 1; + } +} +``` + +--- + +## 3. Deployment Script (Hardhat) + +Create a file: + +`scripts/deploy.js` + +```javascript +const hre = require("hardhat"); + +async function main() { + const Counter = await hre.ethers.getContractFactory("Counter"); + const counter = await Counter.deploy(); + + await counter.waitForDeployment(); + console.log("Counter deployed to:", await counter.getAddress()); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); +``` + +Run the deployment: + +``` +npx hardhat run scripts/deploy.js --network base-sepolia +``` + +--- + +## 4. Minimal Frontend (HTML + JS) + +Create a file: + +`index.html` + +```html + + + + Base Minimal dApp + + +

Base Counter dApp

+ + +

Loading...

+ + + + + +``` + +--- + +## 5. Running the Example + +1. Deploy contract +2. Replace `YOUR_DEPLOYED_CONTRACT_ADDRESS` in `index.html` +3. Open the HTML file in the browser +4. Connect wallet → click “Increment” +5. You now interact with a smart contract on **Base Sepolia** + +--- + +## 6. Notes + +- This is intentionally minimal +- Can be extended using OnchainKit, React, Wagmi, Vite, etc. +- Works on any EVM chain; configured here for Base + +--- + +