diff --git a/apps/base-docs/base-learn/docs/learning-objectives.md b/apps/base-docs/base-learn/docs/learning-objectives.md index d689232050..d71e3573a4 100644 --- a/apps/base-docs/base-learn/docs/learning-objectives.md +++ b/apps/base-docs/base-learn/docs/learning-objectives.md @@ -48,7 +48,7 @@ Use the script to regenerate this file. - Verify a deployed smart contract on Etherscan - Connect a wallet to a contract in Etherscan -- Use etherscan to interact with your own deployed contact +- Use etherscan to interact with your own deployed contract ### [Hardhat Forking](./hardhat-forking/hardhat-forking.md) diff --git a/apps/base-docs/docs/building-with-base/quickstart.md b/apps/base-docs/docs/building-with-base/quickstart.md new file mode 100644 index 0000000000..2d82085465 --- /dev/null +++ b/apps/base-docs/docs/building-with-base/quickstart.md @@ -0,0 +1,161 @@ +--- +title: 'Quickstart: Deploy on Base' +slug: /quickstart +description: A guide to help you get started with deploying your smart contracts on Base. +keywords: + [ + Base, + Base network, + contracts, + Base contracts, + Base quickstart, + smart contracts, + Base smart contracts, + Base Mainnet, + Base Testnet, + ] +hide_table_of_contents: false +--- + +# Quick Start: Deploy on Base + +Welcome to the Base deployment quickstart guide! This comprehensive walkthrough will help you set up your environment and deploy smart contracts on Base. Whether you're a seasoned developer or just starting out, this guide has got you covered. + +## What You'll Achieve + +By the end of this quickstart, you'll be able to: + +- Set up your development environment to deploy on Base +- Deploy your smart contracts to Base +- Connect your frontend to your smart contracts + +:::tip Why Base? + +Base is a fast, low-cost, builder-friendly Ethereum L2 built to bring the next billion users onchain. By following this guide, you'll join a vibrant ecosystem of developers, creators, and innovators who are building a global onchain economy. + +::: + +## Set Up Your Development Environment + +1. Create a new project directory + +```bash +mkdir my-base-project && cd my-base-project +``` + +2. Install Foundry, a powerful framework for smart contract development + +```bash +curl -L https://foundry.paradigm.xyz | bash +foundryup +``` + +This installs Foundry and updates it to the latest version. + +3. Initialize a new Solidity project + +```bash +forge init +``` + +Your Foundry project is now ready. You'll find an example contract in the `src` directory, which you can replace with your own contracts. For the purposes of this guide, we'll use the Counter contract provided in `/src/Counter.sol` + +:::tip +Foundry provides a suite of tools for Ethereum application development, including Forge (for testing), Cast (for interacting with the chain), and Anvil (for setting up a local node). You can learn more about Foundry [here](https://book.getfoundry.sh/). +::: + +## Configure Foundry with Base + +To deploy your smart contracts to Base, you need two key components: + +1. A node connection to interact with the Base network +2. A funded private key to deploy the contract + +Lets set up both of these: + +### 1. Set up your node connection + +1. Create a `.env` file in your project's root directory +2. Add the Base network RPC URL to your `.env` file + +```bash +BASE_RPC_URL="https://mainnet.base.org" +BASE_SEPOLIA_RPC_URL="https://sepolia.base.org" +``` + +3. Load your environment variables + +```bash +source .env +``` + +:::tip +Base Sepolia is the test network for Base, which we will use for the rest of this guide. You can obtain free Base Sepolia ETH from one of the [faucets listed here](/docs/tools/network-faucets). +::: + +### 2. Secure your private key + +1. Store your private key in Foundry's secure keystore + +```bash +cast wallet import deployer --interactive +``` + +2. When prompted enter your private key and a password. + +Your private key is stored in `~/.foundry/keystores` which is not tracked by git. + +:::warning +Never share or commit your private key. Always keep it secure and handle with care. +::: + +## Deploy Your Contracts + +Now that your environment is set up, let's deploy your contracts to Base Sepolia. + +1. Use the following command to compile and deploy your contract + +```bash +forge create ./src/Counter.sol:Counter --rpc-url $BASE_SEPOLIA_RPC_URL --account deployer +``` + +Note the format of the contract being deployed is `:`. + +2. After successful deployment, the transaction hash will be printed to the console output + +3. Copy the deployed contract address and add it to your `.env` file + +```bash +COUNTER_CONTRACT_ADDRESS="0x..." +``` + +4. Load the new environment variable + +```bash +source .env +``` + +### Verify Your Deployment + +To ensure your contract was deployed successfully: + +1. Check the transaction on [Sepolia Basescan](https://sepolia.basescan.org/). +2. Use the `cast` command to interact with your deployed contract from the command line + +```bash +cast call $COUNTER_CONTRACT_ADDRESS "number()(uint256)" --rpc-url $BASE_SEPOLIA_RPC_URL +``` + +This will return the initial value of the Counter contract's `number` storage variable, which will be `0`. + +**Congratulations! You've deployed your smart contracts to Base Sepolia!** + +## Next Steps + +- Use [Onchainkit](https://onchainkit.com) to connect your frontend to your contracts! Onchainkit is a library of ready-to-use React components and Typescript utilities. +- Learn more about interacting with your contracts in the command line using Foundry from our [Foundry tutorial](/tutorials/deploy-with-foundry). + +
+
+
+
diff --git a/apps/base-docs/sidebars.js b/apps/base-docs/sidebars.js index c9f06d82a6..47b4f5db38 100644 --- a/apps/base-docs/sidebars.js +++ b/apps/base-docs/sidebars.js @@ -15,6 +15,7 @@ module.exports = { collapsible: false, collapsed: false, items: [ + 'building-with-base/quickstart', 'building-with-base/network-information', 'building-with-base/base-contracts', 'building-with-base/fees', diff --git a/apps/base-docs/tutorials/data.json b/apps/base-docs/tutorials/data.json index 2f7705c45f..c634c3667d 100644 --- a/apps/base-docs/tutorials/data.json +++ b/apps/base-docs/tutorials/data.json @@ -724,9 +724,9 @@ "difficulty": "intermediate", "hide_table_of_contents": false, "displayed_sidebar": null, - "last_updated": "Sep 13, 2024", + "last_updated": "Sep 26, 2024", "duration": "14 min read", - "checksum": "50ab75b2f4db041666bd7bf24bea0a3079389213810517bd8087807c3528fb0c" + "checksum": "28f843ebc47bc9d69b6bf040a6ec3d1b92237e78a462121d74ff70ab64d66018" }, "2_email-campaign-with-resend": { "title": "Create Email Marketing Campaigns Onchain using Coinbase Smart Wallet + Resend", @@ -1002,9 +1002,9 @@ "difficulty": "beginner", "hide_table_of_contents": false, "displayed_sidebar": null, - "last_updated": "Jul 11, 2024", + "last_updated": "Sep 26, 2024", "duration": "6 min read", - "checksum": "0b50de1197db8c50cbf02405a904f99ec7e32159f86ae884993aa6cc36b10fcb" + "checksum": "9cd3979515e3c4b2ccc8a59c6ac08c9e3d2b69e108c8ddc58ef010f0f77670fa" }, "4_intro-to-foundry-testing": { "title": "Foundry: Testing smart contracts", @@ -1030,6 +1030,35 @@ "duration": "9 min read", "checksum": "2ced64394c425e5749001cb21cca5a3b0043fe6ab013be45e98299e16f337d23" }, + "5_basename-frames": { + "title": "Add Frames to A Basename", + "slug": "/add-frames-to-basename", + "description": "Learn how to customize your Basename by adding Frames, showcasing dynamic content with ease on Base.", + "author": "hughescoin", + "keywords": [ + "Sponsored Transactions", + "Onchain", + "Coinbase", + "Base", + "Crypto", + "Cloud Platform", + "Basenames", + "Frames", + "Profile Customization", + "Open Graph", + "ENS" + ], + "tags": [ + "account abstraction", + "Paymaster" + ], + "difficulty": "easy", + "hide_table_of_contents": false, + "displayed_sidebar": null, + "last_updated": "Sep 26, 2024", + "duration": "5 min read", + "checksum": "17b2137efd031251de2beb3683b5c75006b8723bff189e59d655d86f5abc296d" + }, "5_cross-chain-with-ccip": { "title": "Sending messages and tokens from Base to other chains using Chainlink CCIP", "slug": "/cross-chain-with-ccip", @@ -1076,9 +1105,9 @@ ], "difficulty": "intermediate", "displayed_sidebar": null, - "last_updated": "Aug 14, 2024", + "last_updated": "Sep 26, 2024", "duration": "34 min read", - "checksum": "5b2ccc63f23434488c8404f76547707a8b83601215bdbac8e729ca05444bc955" + "checksum": "0f984180e209b250b61c437f6cb53af4695e73e5c08297d09bd64f25a2b20122" }, "5_deploy-with-fleek": { "title": "Deploy an Onchain App with Fleek", @@ -1128,9 +1157,9 @@ ], "difficulty": "intermediate", "displayed_sidebar": null, - "last_updated": "Aug 14, 2024", + "last_updated": "Sep 26, 2024", "duration": "11 min read", - "checksum": "3a230905924424d5d065346fc2ea6a3e253836f31852fe6b2b4301995d107016" + "checksum": "0abeee6a45dc60ad4e4c5945dc7ba2e9094c731c7353914365ef268edc10f789" }, "5_oracles-pyth-price-feeds": { "title": "Accessing real-time asset data using Pyth Price Feeds", @@ -1230,4 +1259,4 @@ "duration": "8 min read", "checksum": "59d04f2a46bc95b68a0f50c83f78a0b0d2f2549ecf0e8c7e592aaa4eae6bf6d1" } -} +} \ No newline at end of file