mirror of
https://github.com/placeholder-soft/web.git
synced 2026-06-15 09:28:21 +08:00
Update guides and docs with Sepolia (#233)
* Update guides with Sepolia * Update docs with Sepolia
This commit is contained in:
@@ -101,7 +101,7 @@ The first thing is the Solidity version.
|
||||
|
||||
As of December 2023, Base does not support the new PUSH0 opcode introduced in Shanghai, which is the default target for the Solidity compiler if you use version 0.8.20 or later. See [Differences between Ethereum and Base] to learn more.
|
||||
|
||||
We recommend using 0.8.19 or lower until Base is upgraded with `PUSH0`. Keep in mind that the update has been deployed to Base Goerli and Base Sepolia.
|
||||
We recommend using 0.8.19 or lower until Base is upgraded with `PUSH0`. Keep in mind that the update has been deployed to Base Sepolia.
|
||||
|
||||
:::
|
||||
|
||||
@@ -130,14 +130,14 @@ solc_version = "0.8.19"
|
||||
|
||||
[rpc_endpoints]
|
||||
base = "https://mainnet.base.org"
|
||||
baseGoerli = "https://goerli.base.org"
|
||||
baseSepolia = "https://sepolia.base.org"
|
||||
|
||||
[etherscan]
|
||||
baseGoerli = { key = "${BASESCAN_API_KEY}", url = "https://api-goerli.basescan.org/api" }
|
||||
baseSepolia = { key = "${BASESCAN_API_KEY}", url = "https://api-sepolia.basescan.org/api" }
|
||||
base = { key = "${BASESCAN_API_KEY}", url = "https://api.basescan.org/api" }
|
||||
```
|
||||
|
||||
We included 2 JSON RPC endpoints for `Base` and `Base goerli` and similar for the Etherscan section, we included the configuration for `Basescan` for goerli and mainnet. Both rely on the same API Key, `BASESCAN_API_KEY`.
|
||||
We included 2 JSON RPC endpoints for `Base` and `Base Sepolia` and similar for the Etherscan section, we included the configuration for `Basescan` for Sepolia and Mainnet. Both rely on the same API Key, `BASESCAN_API_KEY`.
|
||||
|
||||
## Conclusion
|
||||
|
||||
|
||||
@@ -50,12 +50,7 @@ In order to deploy a smart contract, you will first need a web3 wallet. You can
|
||||
|
||||
Deploying contracts to the blockchain requires a gas fee. Therefore, you will need to fund your wallet with ETH to cover those gas fees.
|
||||
|
||||
For this guide, you will be deploying a contract to the Base Goerli test network. You can fund your wallet with Base Goerli ETH using the following options:
|
||||
|
||||
- [Coinbase Faucet | Base Goerli](https://www.coinbase.com/faucets/base-ethereum-goerli-faucet)
|
||||
- [Coinbase Wallet Faucets](https://chrome.google.com/webstore/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad)
|
||||
|
||||
For more detailed steps on funding your wallet with Base Goerli ETH, see [Network Faucets](/tools/network-faucets).
|
||||
For this guide, you will be deploying a contract to the Base Sepolia test network. You can fund your wallet with Base Sepolia ETH using one of the faucets listed on the Base [Network Faucets](https://docs.base.org/tools/network-faucets) page.
|
||||
|
||||
---
|
||||
|
||||
@@ -113,8 +108,8 @@ const config: HardhatUserConfig = {
|
||||
gasPrice: 1000000000,
|
||||
},
|
||||
// for testnet
|
||||
'base-goerli': {
|
||||
url: 'https://goerli.base.org',
|
||||
'base-sepolia': {
|
||||
url: 'https://sepolia.base.org',
|
||||
accounts: [process.env.WALLET_KEY as string],
|
||||
gasPrice: 1000000000,
|
||||
},
|
||||
@@ -218,9 +213,9 @@ npx hardhat compile
|
||||
|
||||
## Deploying the smart contract
|
||||
|
||||
Once your contract has been successfully compiled, you can deploy the contract to the Base Goerli test network.
|
||||
Once your contract has been successfully compiled, you can deploy the contract to the Base Sepolia test network.
|
||||
|
||||
To deploy the contract to the Base Goerli test network, you'll need to modify the `scripts/deploy.ts` in your project:
|
||||
To deploy the contract to the Base Sepolia test network, you'll need to modify the `scripts/deploy.ts` in your project:
|
||||
|
||||
```typescript
|
||||
import { ethers } from 'hardhat';
|
||||
@@ -246,10 +241,10 @@ You'll also need testnet ETH in your wallet. See the [prerequisites](#prerequisi
|
||||
Finally, run:
|
||||
|
||||
```bash
|
||||
npx hardhat run scripts/deploy.ts --network base-goerli
|
||||
npx hardhat run scripts/deploy.ts --network base-sepolia
|
||||
```
|
||||
|
||||
The contract will be deployed on the Base Goerli test network. You can view the deployment status and contract by using a [block explorer](/tools/block-explorers) and searching for the address returned by your deploy script. If you've deployed an exact copy of the NFT contract above, it will already be verified and you'll be able to read and write to the contract using the web interface.
|
||||
The contract will be deployed on the Base Sepolia test network. You can view the deployment status and contract by using a [block explorer](/tools/block-explorers) and searching for the address returned by your deploy script. If you've deployed an exact copy of the NFT contract above, it will already be verified and you'll be able to read and write to the contract using the web interface.
|
||||
|
||||
:::info
|
||||
|
||||
@@ -267,9 +262,9 @@ Regardless of the network you're deploying to, if you're deploying a new or modi
|
||||
|
||||
## Verifying the Smart Contract
|
||||
|
||||
If you want to interact with your contract on the block explorer, you, or someone, needs to verify it first. The above contract has already been verified, so you should be able to view your version on a block explorer already. For the remainder of this guide, we'll walk through how to verify your contract on Base Goerli testnet.
|
||||
If you want to interact with your contract on the block explorer, you, or someone, needs to verify it first. The above contract has already been verified, so you should be able to view your version on a block explorer already. For the remainder of this guide, we'll walk through how to verify your contract on Base Sepolia testnet.
|
||||
|
||||
In `hardhat.config.ts`, configure Base Goerli as a custom network. Add the following to your `HardhatUserConfig`:
|
||||
In `hardhat.config.ts`, configure Base Sepolia as a custom network. Add the following to your `HardhatUserConfig`:
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="basescan" label="Basescan">
|
||||
@@ -277,15 +272,15 @@ In `hardhat.config.ts`, configure Base Goerli as a custom network. Add the follo
|
||||
```typescript
|
||||
etherscan: {
|
||||
apiKey: {
|
||||
"base-goerli": "PLACEHOLDER_STRING"
|
||||
"base-sepolia": "PLACEHOLDER_STRING"
|
||||
},
|
||||
customChains: [
|
||||
{
|
||||
network: "base-goerli",
|
||||
chainId: 84531,
|
||||
network: "base-sepolia",
|
||||
chainId: 84532,
|
||||
urls: {
|
||||
apiURL: "https://api-goerli.basescan.org/api",
|
||||
browserURL: "https://goerli.basescan.org"
|
||||
apiURL: "https://api-sepolia.basescan.org/api",
|
||||
browserURL: "https://sepolia.basescan.org"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -294,7 +289,7 @@ etherscan: {
|
||||
|
||||
:::info
|
||||
|
||||
When verifying a contract with Basescan on testnet (Goerli), an API key is not required. You can leave the value as `PLACEHOLDER_STRING`. On mainnet, you can get your Basescan API key from [here](https://basescan.org/myapikey) after you sign up for an account.
|
||||
When verifying a contract with Basescan on testnet (Sepolia), an API key is not required. You can leave the value as `PLACEHOLDER_STRING`. On mainnet, you can get your Basescan API key from [here](https://basescan.org/myapikey) after you sign up for an account.
|
||||
|
||||
:::
|
||||
|
||||
@@ -305,15 +300,15 @@ When verifying a contract with Basescan on testnet (Goerli), an API key is not r
|
||||
// Hardhat expects etherscan here, even if you're using Blockscout.
|
||||
etherscan: {
|
||||
apiKey: {
|
||||
"base-goerli": process.env.BLOCKSCOUT_KEY as string
|
||||
"base-sepolia": process.env.BLOCKSCOUT_KEY as string
|
||||
},
|
||||
customChains: [
|
||||
{
|
||||
network: "base-goerli",
|
||||
chainId: 84531,
|
||||
network: "base-sepolia",
|
||||
chainId: 84532,
|
||||
urls: {
|
||||
apiURL: "https://base-goerli.blockscout.com/api",
|
||||
browserURL: "https://base-goerli.blockscout.com"
|
||||
apiURL: "https://base-sepolia.blockscout.com/api",
|
||||
browserURL: "https://base-sepolia.blockscout.com"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -322,7 +317,7 @@ etherscan: {
|
||||
|
||||
:::info
|
||||
|
||||
You can get your Blockscout API key from [here](https://base-goerli.blockscout.com/account/api_key) after you sign up for an account.
|
||||
You can get your Blockscout API key from [here](https://base-sepolia.blockscout.com/account/api_key) after you sign up for an account.
|
||||
|
||||
:::
|
||||
|
||||
@@ -332,7 +327,7 @@ You can get your Blockscout API key from [here](https://base-goerli.blockscout.c
|
||||
Now, you can verify your contract. Grab the deployed address and run:
|
||||
|
||||
```bash
|
||||
npx hardhat verify --network base-goerli <deployed address>
|
||||
npx hardhat verify --network base-sepolia <deployed address>
|
||||
```
|
||||
|
||||
You should see an output similar to:
|
||||
@@ -348,7 +343,6 @@ contracts/NFT.sol:NFT at 0x6527E5052de5521fE370AE5ec0aFCC6cD5a221de
|
||||
for verification on the block explorer. Waiting for verification result...
|
||||
|
||||
Successfully verified contract NFT on Etherscan.
|
||||
https://goerli.basescan.org/address/0x6527E5052de5521fE370AE5ec0aFCC6cD5a221de#code
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -362,7 +356,6 @@ contracts/NFT.sol:NFT at 0x6527E5052de5521fE370AE5ec0aFCC6cD5a221de
|
||||
for verification on the block explorer. Waiting for verification result...
|
||||
|
||||
Successfully verified contract NFT on Etherscan.
|
||||
https://base-goerli.blockscout.com/address/0x6527E5052de5521fE370AE5ec0aFCC6cD5a221de#code
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
@@ -380,7 +373,7 @@ Message: Already Verified
|
||||
|
||||
:::
|
||||
|
||||
Search for your contract on [Blockscout](https://base-goerli.blockscout.com/) or [Basescan](https://goerli.basescan.org/) to confirm it is verified.
|
||||
Search for your contract on [Blockscout](https://base-sepolia.blockscout.com/) or [Basescan](https://sepolia.basescan.org/) to confirm it is verified.
|
||||
|
||||
## Interacting with the Smart Contract
|
||||
|
||||
|
||||
@@ -9,9 +9,10 @@ keywords: ["Foundry", "smart contract", "ERC-721", "Base", "Base test network",
|
||||
|
||||
# Deploying a Smart Contract using Foundry
|
||||
|
||||
This article will provide an overview of the [Foundry](https://book.getfoundry.sh/) development toolchain, and show you how to deploy a contract to **Base Goerli** testnet.
|
||||
This article will provide an overview of the [Foundry](https://book.getfoundry.sh/) development toolchain, and show you how to deploy a contract to **Base Sepolia** testnet.
|
||||
|
||||
Foundry is a powerful suite of tools to develop, test, and debug your smart contracts. It is comprised of several individual tools:
|
||||
|
||||
- `forge`: the main workhorse of Foundry — for developing, testing, compiling, and deploying smart contracts
|
||||
- `cast`: a command-line tool for performing Ethereum RPC calls (e.g. interacting with contracts, sending transactions, and getting onchain data)
|
||||
- `anvil`: a local testnet node, for testing contract behavior from a frontend or over RPC
|
||||
@@ -21,7 +22,7 @@ Foundry offers extremely fast feedback loops (due to the under-the-hood Rust imp
|
||||
|
||||
:::info
|
||||
|
||||
For production / mainnet deployments the steps below in this guide will be almost identical, however, you'll want to ensure that you've configured `Base` (mainnet) as the network rather than `Base Goerli` (testnet).
|
||||
For production / mainnet deployments the steps below in this guide will be almost identical, however, you'll want to ensure that you've configured `Base` (mainnet) as the network rather than `Base Sepolia` (testnet).
|
||||
|
||||
:::
|
||||
|
||||
@@ -60,12 +61,7 @@ In order to deploy a smart contract, you will first need a web3 wallet. You can
|
||||
|
||||
Deploying contracts to the blockchain requires a gas fee. Therefore, you will need to fund your wallet with ETH to cover those gas fees.
|
||||
|
||||
For this guide, you will be deploying a contract to the Base Goerli test network. You can fund your wallet with Base Goerli ETH using the following options:
|
||||
|
||||
- [Coinbase Faucet | Base Goerli](https://www.coinbase.com/faucets/base-ethereum-goerli-faucet)
|
||||
- [Coinbase Wallet Faucets](https://chrome.google.com/webstore/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad)
|
||||
|
||||
For more detailed steps on funding your wallet with Base Goerli ETH, see [Network Faucets](/tools/network-faucets).
|
||||
For this guide, you will be deploying a contract to the Base Sepolia test network. You can fund your wallet with Base Sepolia ETH using one of the faucets listed on the Base [Network Faucets](https://docs.base.org/tools/network-faucets) page.
|
||||
|
||||
---
|
||||
|
||||
@@ -172,15 +168,15 @@ Now create a `.env` file in the home directory of your project to add the Base n
|
||||
|
||||
```
|
||||
BASE_MAINNET_RPC="https://mainnet.base.org"
|
||||
BASE_GOERLI_RPC="https://goerli.base.org"
|
||||
BASE_SEPOLIA_RPC="https://sepolia.base.org"
|
||||
ETHERSCAN_API_KEY="PLACEHOLDER_STRING"
|
||||
```
|
||||
|
||||
Note that even though we're using Basescan as our block explorer, Foundry expects the API key to be defined as `ETHERSCAN_API_KEY`.
|
||||
Note that even though we're using Basescan as our block explorer, Foundry expects the API key to be defined as `ETHERSCAN_API_KEY`.
|
||||
|
||||
:::info
|
||||
|
||||
When verifying a contract with Basescan on testnet (Goerli), an API key is not required. You can leave the value as `PLACEHOLDER_STRING`. On mainnet, you can get your Basescan API key from [here](https://basescan.org/myapikey) after you sign up for an account.
|
||||
When verifying a contract with Basescan on testnet (Sepolia), an API key is not required. You can leave the value as `PLACEHOLDER_STRING`. On mainnet, you can get your Basescan API key from [here](https://basescan.org/myapikey) after you sign up for an account.
|
||||
|
||||
:::
|
||||
|
||||
@@ -195,19 +191,20 @@ source .env
|
||||
---
|
||||
|
||||
## Deploying the smart contract
|
||||
With your contract compiled and your environment configured, you are ready to deploy to the Base Goerli test network!
|
||||
|
||||
With your contract compiled and your environment configured, you are ready to deploy to the Base Sepolia test network!
|
||||
|
||||
Today we'll use the `forge create` command, which is a straightforward way to deploy a single contract at a time. In the future, you may want to look into [`forge script`](https://book.getfoundry.sh/tutorials/solidity-scripting), which enables scripting onchain transactions and deploying more complex smart contract projects.
|
||||
|
||||
You'll need testnet ETH in your wallet. See the [prerequisites](#prerequisites) if you haven't done that yet. Otherwise, the deployment attempt will fail.
|
||||
|
||||
To deploy the contract to the Base Goerli test network, run the following command. You will be prompted to enter the password that you set earlier, when you imported your private key:
|
||||
To deploy the contract to the Base Sepolia test network, run the following command. You will be prompted to enter the password that you set earlier, when you imported your private key:
|
||||
|
||||
```bash
|
||||
forge create ./src/NFT.sol:NFT --rpc-url $BASE_GOERLI_RPC --account deployer
|
||||
forge create ./src/NFT.sol:NFT --rpc-url $BASE_SEPOLIA_RPC --account deployer
|
||||
```
|
||||
|
||||
The contract will be deployed on the Base Goerli test network. You can view the deployment status and contract by using a [block explorer](/tools/block-explorers) and searching for the address returned by your deploy script. If you've deployed an exact copy of the NFT contract above, it will already be verified and you'll be able to read and write to the contract using the web interface.
|
||||
The contract will be deployed on the Base Sepolia test network. You can view the deployment status and contract by using a [block explorer](/tools/block-explorers) and searching for the address returned by your deploy script. If you've deployed an exact copy of the NFT contract above, it will already be verified and you'll be able to read and write to the contract using the web interface.
|
||||
|
||||
:::info
|
||||
|
||||
@@ -224,33 +221,34 @@ Regardless of the network you're deploying to, if you're deploying a new or modi
|
||||
---
|
||||
|
||||
## Verifying the Smart Contract
|
||||
|
||||
In web3, it's considered best practice to verify your contracts so that users and other developers can inspect the source code, and be sure that it matches the deployed bytecode on the blockchain.
|
||||
|
||||
Further, if you want to allow others to interact with your contract using the block explorer, it first needs to be verified. The above contract has already been verified, so you should be able to view your version on a block explorer already, but we'll still walk through how to verify a contract on Base Goerli testnet.
|
||||
Further, if you want to allow others to interact with your contract using the block explorer, it first needs to be verified. The above contract has already been verified, so you should be able to view your version on a block explorer already, but we'll still walk through how to verify a contract on Base Sepolia testnet.
|
||||
|
||||
:::info
|
||||
|
||||
When verifying a contract with Basescan on testnet (Goerli), an API key is not required. You can leave the value as `PLACEHOLDER_STRING`. On mainnet, you can get your Basescan API key from [here](https://basescan.org/myapikey) after you sign up for an account.
|
||||
When verifying a contract with Basescan on testnet (Sepolia), an API key is not required. You can leave the value as `PLACEHOLDER_STRING`. On mainnet, you can get your Basescan API key from [here](https://basescan.org/myapikey) after you sign up for an account.
|
||||
|
||||
:::
|
||||
|
||||
Grab the deployed address and run:
|
||||
|
||||
```bash
|
||||
forge verify-contract <DEPLOYED_ADDRESS> ./src/NFT.sol:NFT --chain 84531 --watch
|
||||
forge verify-contract <DEPLOYED_ADDRESS> ./src/NFT.sol:NFT --chain 84532 --watch
|
||||
```
|
||||
|
||||
You should see an output similar to:
|
||||
|
||||
```
|
||||
Start verifying contract `0x71bfCe1172A66c1c25A50b49156FAe45EB56E009` deployed on base-goerli
|
||||
Start verifying contract `0x71bfCe1172A66c1c25A50b49156FAe45EB56E009` deployed on base-sepolia
|
||||
|
||||
Submitting verification for [src/NFT.sol:NFT] 0x71bfCe1172A66c1c25A50b49156FAe45EB56E009.
|
||||
Submitted contract for verification:
|
||||
Response: `OK`
|
||||
GUID: `3i9rmtmtyyzkqpfvy7pcxj1wtgqyuybvscnq8d7ywfuskss1s7`
|
||||
URL:
|
||||
https://goerli.basescan.org/address/0x71bfce1172a66c1c25a50b49156fae45eb56e009
|
||||
https://sepolia.basescan.org/address/0x71bfce1172a66c1c25a50b49156fae45eb56e009
|
||||
Contract verification status:
|
||||
Response: `NOTOK`
|
||||
Details: `Pending in queue`
|
||||
@@ -260,14 +258,14 @@ Details: `Pass - Verified`
|
||||
Contract successfully verified
|
||||
```
|
||||
|
||||
Search for your contract on [Basescan](https://goerli.basescan.org/) to confirm it is verified.
|
||||
Search for your contract on [Basescan](https://sepolia.basescan.org/) to confirm it is verified.
|
||||
|
||||
:::info
|
||||
|
||||
You can't re-verify a contract identical to one that has already been verified. If you attempt to do so, such as verifying the above contract, you'll get an error similar to:
|
||||
|
||||
```text
|
||||
Start verifying contract `0x71bfCe1172A66c1c25A50b49156FAe45EB56E009` deployed on base-goerli
|
||||
Start verifying contract `0x71bfCe1172A66c1c25A50b49156FAe45EB56E009` deployed on base-sepolia
|
||||
|
||||
Contract [src/NFT.sol:NFT] "0x71bfCe1172A66c1c25A50b49156FAe45EB56E009" is already verified. Skipping verification.
|
||||
```
|
||||
@@ -276,28 +274,30 @@ Contract [src/NFT.sol:NFT] "0x71bfCe1172A66c1c25A50b49156FAe45EB56E009" is alrea
|
||||
|
||||
## Interacting with the Smart Contract
|
||||
|
||||
If you verified on Basescan, you can use the `Read Contract` and `Write Contract` sections under the `Contract` tab to interact with the deployed contract. To use `Write Contract`, you'll need to connect your wallet first, by clicking the `Connect to Web3` button (sometimes this can be a little finicky, and you'll need to click `Connect` twice before it shows your wallet is successfully connected).
|
||||
If you verified on Basescan, you can use the `Read Contract` and `Write Contract` sections under the `Contract` tab to interact with the deployed contract. To use `Write Contract`, you'll need to connect your wallet first, by clicking the `Connect to Web3` button (sometimes this can be a little finicky, and you'll need to click `Connect` twice before it shows your wallet is successfully connected).
|
||||
|
||||
To practice using the `cast` command-line tool which Foundry provides, we'll perform a call without publishing a transaction (a read), then sign and publish a transaction (a write).
|
||||
|
||||
### Performing a call
|
||||
|
||||
A key component of the Foundry toolkit, `cast` enables us to interact with contracts, send transactions, and get onchain data using Ethereum RPC calls. First we will perform a call from your account, without publishing a transaction.
|
||||
|
||||
From the command-line, run:
|
||||
|
||||
```bash
|
||||
cast call <DEPLOYED_ADDRESS> --rpc-url $BASE_GOERLI_RPC "balanceOf(address)" <YOUR_ADDRESS_HERE>
|
||||
cast call <DEPLOYED_ADDRESS> --rpc-url $BASE_SEPOLIA_RPC "balanceOf(address)" <YOUR_ADDRESS_HERE>
|
||||
```
|
||||
|
||||
You should receive `0x0000000000000000000000000000000000000000000000000000000000000000` in response, which equals `0` in hexadecimal. And that makes sense — while you've deployed the NFT contract, no NFTs have been minted yet and therefore your account's balance is zero.
|
||||
|
||||
### Signing and publishing a transaction
|
||||
|
||||
Now let's sign and publish a transaction, calling the `mint(address)` function on the NFT contract we just deployed.
|
||||
|
||||
Run the following command:
|
||||
|
||||
```bash
|
||||
cast send <DEPLOYED_ADDRESS> --rpc-url=$BASE_GOERLI_RPC "mint(address)" <YOUR_ADDRESS_HERE> --account deployer
|
||||
cast send <DEPLOYED_ADDRESS> --rpc-url=$BASE_SEPOLIA_RPC "mint(address)" <YOUR_ADDRESS_HERE> --account deployer
|
||||
```
|
||||
|
||||
:::info
|
||||
@@ -311,7 +311,7 @@ If successful, Foundry will respond with information about the transaction, incl
|
||||
Finally, let's confirm that we did indeed mint ourselves one NFT. If we run the first `cast call` command again, we should see that our balance increased from 0 to 1:
|
||||
|
||||
```bash
|
||||
cast call <DEPLOYED_ADDRESS> --rpc-url $BASE_GOERLI_RPC "balanceOf(address)" <YOUR_ADDRESS_HERE>
|
||||
cast call <DEPLOYED_ADDRESS> --rpc-url $BASE_SEPOLIA_RPC "balanceOf(address)" <YOUR_ADDRESS_HERE>
|
||||
```
|
||||
|
||||
And the response: `0x0000000000000000000000000000000000000000000000000000000000000001` (`1` in hex) — congratulations, you deployed a contract and minted an NFT with Foundry!
|
||||
@@ -328,7 +328,7 @@ For all things Foundry, check out the [Foundry book](https://book.getfoundry.sh/
|
||||
|
||||
<!-- Add reference style links here. These do not render on the page. -->
|
||||
|
||||
[`goerli.basescan.org`]: https://goerli.basescan.org/
|
||||
[`sepolia.basescan.org`]: https://sepolia.basescan.org/
|
||||
[`basescan.org`]: https://basescan.org/
|
||||
[coinbase]: https://www.coinbase.com/wallet
|
||||
[MetaMask]: https://metamask.io/
|
||||
|
||||
@@ -12,11 +12,11 @@ keywords: ["Remix", "Remix IDE", "smart contract", "Base", "Base test network",
|
||||
|
||||
Remix contains a simulation of a blockchain that you can use to rapidly deploy and test your contracts. This simulation only exists within your browser, so you can't share it with others or use external tools or a front end to interact with it. However, you can also deploy to a variety of testnets from within Remix. Doing so will allow you to share your contract with others, at the cost of making it public.
|
||||
|
||||
In this article, we'll give you an overview of Remix, and show you how to deploy a contract to **Base Goerli** testnet.
|
||||
In this article, we'll give you an overview of Remix, and show you how to deploy a contract to **Base Sepolia** testnet.
|
||||
|
||||
:::info
|
||||
|
||||
For production / mainnet deployments the steps below in this guide will be almost identical, however, you'll want to ensure that you've selected `Base` (mainnet) as the network rather than `Base Goerli` (testnet).
|
||||
For production / mainnet deployments the steps below in this guide will be almost identical, however, you'll want to ensure that you've selected `Base` (mainnet) as the network rather than `Base Sepolia` (testnet).
|
||||
|
||||
:::
|
||||
|
||||
@@ -30,7 +30,7 @@ By the end of this lesson you should be able to:
|
||||
|
||||
- List the features, pros, and cons of using Remix as an IDE
|
||||
- Deploy and test the Storage.sol demo contract in Remix
|
||||
- Use Remix to deploy a contract to the Base @ Goerli testnet and interact with it in Etherscan
|
||||
- Use Remix to deploy a contract to the Base @ Sepolia testnet and interact with it in Etherscan
|
||||
|
||||
---
|
||||
|
||||
@@ -112,18 +112,13 @@ First, add the [Coinbase] or [MetaMask] wallet to your browser, and [set up] a n
|
||||
|
||||
Once you've completed wallet setup, enable developer settings and turn on testnets ([Coinbase Settings], [MetaMask Settings]).
|
||||
|
||||
### Add the Base Goerli Network to your Wallet
|
||||
### Add the Base Sepolia Network to your Wallet
|
||||
|
||||
For this guide, you will be deploying a contract to the Base Goerli test network. You can fund your wallet with Base Goerli ETH using the following options:
|
||||
|
||||
- [Coinbase Faucet | Base Goerli](https://www.coinbase.com/faucets/base-ethereum-goerli-faucet)
|
||||
- [Coinbase Wallet Faucets](https://chrome.google.com/webstore/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad)
|
||||
|
||||
For more detailed steps on funding your wallet with Base Goerli ETH, see [Network Faucets](/tools/network-faucets).
|
||||
For this guide, you will be deploying a contract to the Base Sepolia test network. You can fund your wallet with Base Sepolia ETH using one of the faucets listed on the Base [Network Faucets](https://docs.base.org/tools/network-faucets) page.
|
||||
|
||||
### Get Testnet Ether
|
||||
|
||||
Testnet tokens have no real value, but the supply is not unlimited. You can use a faucet to get a small amount of Goerli Ether to pay gas fees for testing. Most faucets allow you to ask for a small amount each day, and some won't send you more if your balance is too high.
|
||||
Testnet tokens have no real value, but the supply is not unlimited. You can use a faucet to get a small amount of Sepolia Ether to pay gas fees for testing. Most faucets allow you to ask for a small amount each day, and some won't send you more if your balance is too high.
|
||||
|
||||
You can find many faucets by searching, and it's good to keep a few bookmarked because they have a tendency to go down from time to time. Faucet providers are constantly combating bad actors and sometimes need to disable their faucets while doing so.
|
||||
|
||||
@@ -131,7 +126,7 @@ The Coinbase Wallet has faucets built in. Find them by clicking Settings -> Deve
|
||||
|
||||
You can also access the [faucets on the web].
|
||||
|
||||
Once you have testnet Base Goerli Ether, you can view your balance under the _Testnets_ tab in the Coinbase wallet, or by selecting the testnet from the network dropdown in MetaMask. Sadly, it's not actually worth the amount listed!
|
||||
Once you have testnet Base Sepolia Ether, you can view your balance under the _Testnets_ tab in the Coinbase wallet, or by selecting the testnet from the network dropdown in MetaMask. Sadly, it's not actually worth the amount listed!
|
||||
|
||||
---
|
||||
|
||||
@@ -151,7 +146,7 @@ Once you are connected, you'll see the name of the network below the _Environmen
|
||||
|
||||

|
||||
|
||||
For Base Goerli, you should see `Custom (84531) network` (**note:** if you're deploying to mainnet rather than testnet, you should see `Custom (8453) network` instead).
|
||||
For Base Sepolia, you should see `Custom (84532) network` (**note:** if you're deploying to mainnet rather than testnet, you should see `Custom (8453) network` instead).
|
||||
|
||||
If you don't see the correct network, change the active network in your wallet.
|
||||
|
||||
@@ -167,7 +162,7 @@ Always carefully review all transactions, confirming the transaction cost, asset
|
||||
|
||||
:::
|
||||
|
||||
After you click the _Confirm_ button, return to Remix and wait for the transaction to deploy. Copy its address and navigate to [`goerli.basescan.org`]. **Note:** If you deployed to mainnet, you'll navigate to [`basescan.org`] instead.
|
||||
After you click the _Confirm_ button, return to Remix and wait for the transaction to deploy. Copy its address and navigate to [`sepolia.basescan.org`]. **Note:** If you deployed to mainnet, you'll navigate to [`basescan.org`] instead.
|
||||
|
||||
### Verify the Contract
|
||||
|
||||
@@ -217,7 +212,7 @@ You now have the power to put smart contracts on the blockchain! You've only dep
|
||||
|
||||
<!-- Add reference style links here. These do not render on the page. -->
|
||||
|
||||
[`goerli.basescan.org`]: https://goerli.basescan.org/
|
||||
[`sepolia.basescan.org`]: https://sepolia.basescan.org/
|
||||
[`basescan.org`]: https://basescan.org/
|
||||
[coinbase]: https://www.coinbase.com/wallet
|
||||
[MetaMask]: https://metamask.io/
|
||||
|
||||
@@ -56,7 +56,7 @@ You'll encounter providers divided into three general categories: Public Provide
|
||||
|
||||
Many tutorials and guides, including the getting started guide for [wagmi], use a _Public Provider_ as the default to get you up and running. Public means that they're open, permissionless, and free, so the guides will also usually warn you that you need to add another provider if you don't want to run into rate limiting. Listen to these warnings! The rate-limits of public providers are severe and you'll start getting limited very quickly.
|
||||
|
||||
In wagmi, the `publicClient` is just a wrapper setting up a [JSON RPC] provider using the `chain` and `rpcUrls` listed in Viem's directory of chain information. For example, you can view the [data for Base Goerli here].
|
||||
In wagmi, the `publicClient` is just a wrapper setting up a [JSON RPC] provider using the `chain` and `rpcUrls` listed in Viem's directory of chain information. For example, you can view the [data for Base Sepolia here].
|
||||
|
||||
Most chains will list this information in their docs as well. For example, on the network information pages for [Base] and [Optimism]. If you wanted, you could manually set up a `jsonRpcProvider` in wagmi using this information.
|
||||
|
||||
@@ -99,7 +99,7 @@ In this article, you've learned how Providers supply blockchain connection as a
|
||||
|
||||
[Subgraph]: https://thegraph.com/docs/en/developing/creating-a-subgraph/
|
||||
[wagmi]: https://wagmi.sh/react/getting-started#configure-chains
|
||||
[data for Base Goerli here]: https://github.com/wagmi-dev/viem/blob/main/src/chains/definitions/baseGoerli.ts
|
||||
[data for Base Sepolia here]: https://github.com/wagmi-dev/viem/blob/main/src/chains/definitions/baseSepolia.ts
|
||||
[Base]: https://docs.base.org/network-information
|
||||
[Optimism]: https://community.optimism.io/docs/useful-tools/networks/
|
||||
[EIP-1193]: https://eips.ethereum.org/EIPS/eip-1193
|
||||
|
||||
@@ -144,7 +144,7 @@ On the next screen, you'll be asked to select a chain. Each endpoint only works
|
||||
|
||||

|
||||
|
||||
For now, pick `Base Mainnet`, but you'll probably want to delete this endpoint and create a new one for Goerli or Sepolia when you start building. The free tier only allows you to have one at a time.
|
||||
For now, pick `Base Mainnet`, but you'll probably want to delete this endpoint and create a new one for Sepolia when you start building. The free tier only allows you to have one at a time.
|
||||
|
||||
If you haven't already picked a tier, you'll be asked to do so, then you'll be taken to the endpoints page, which will display your endpoints for HTTP and WSS.
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ Select your preferred bridging framework and use it to deploy an ERC-20 for your
|
||||
|
||||
### Step 2: Submit details for your token
|
||||
|
||||
Follow the instructions in the [GitHub repository](https://github.com/ethereum-optimism/ethereum-optimism.github.io) and submit a PR containing the required details for your token. You must specify in your token's data.json file a section for ‘base-goerli’ and/or ‘base’ . The change you need to submit is particularly simple if your token has already been added to the Optimism token list. For example, [this PR](https://github.com/ethereum-optimism/ethereum-optimism.github.io/commit/27ab9b2d3388f7feba3a152e0a0748c73d732a68) shows the change required for cbETH, which was already on Optimism's token list and relies on the Base standard bridge.
|
||||
Follow the instructions in the [GitHub repository](https://github.com/ethereum-optimism/ethereum-optimism.github.io) and submit a PR containing the required details for your token. You must specify in your token's data.json file a section for ‘base-sepolia and/or ‘base’ . The change you need to submit is particularly simple if your token has already been added to the Optimism token list. For example, [this PR](https://github.com/ethereum-optimism/ethereum-optimism.github.io/commit/27ab9b2d3388f7feba3a152e0a0748c73d732a68) shows the change required for cbETH, which was already on Optimism's token list and relies on the Base standard bridge.
|
||||
|
||||
### Step 3: Await final approval
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ const provider = new ethers.providers.JsonRpcProvider(url);
|
||||
|
||||
:::info
|
||||
|
||||
To alternatively connect to Base Goerli (testnet), change the above URL from `https://mainnet.base.org` to `https://goerli.base.org`.
|
||||
To alternatively connect to Base Sepolia (testnet), change the above URL from `https://mainnet.base.org` to `https://sepolia.base.org`.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
@@ -2,7 +2,24 @@
|
||||
title: Foundry
|
||||
slug: /tools/foundry
|
||||
description: Documentation for Foundry, a toolchain for smart contract development. Provides instructions on deploying and verifying contracts on Base's mainnet and testnet using Foundry.
|
||||
keywords: [Foundry, Forge, Foundry Book, smart contract development, toolchain, Base, Base mainnet, Base testnet, Base network, RPC URL, chain id, deploying contracts, verifying contracts, mainnet, testnet]
|
||||
keywords:
|
||||
[
|
||||
Foundry,
|
||||
Forge,
|
||||
Foundry Book,
|
||||
smart contract development,
|
||||
toolchain,
|
||||
Base,
|
||||
Base mainnet,
|
||||
Base testnet,
|
||||
Base network,
|
||||
RPC URL,
|
||||
chain id,
|
||||
deploying contracts,
|
||||
verifying contracts,
|
||||
mainnet,
|
||||
testnet,
|
||||
]
|
||||
---
|
||||
|
||||
# Foundry
|
||||
@@ -40,11 +57,11 @@ forge verify-contract ... --chain-id 8453
|
||||
### Deploying a smart contract
|
||||
|
||||
```bash
|
||||
forge create ... --rpc-url=https://goerli.base.org/
|
||||
forge create ... --rpc-url=https://sepolia.base.org/
|
||||
```
|
||||
|
||||
### Verifying a smart contract
|
||||
|
||||
```bash
|
||||
forge verify-contract ... --chain-id 84531
|
||||
forge verify-contract ... --chain-id 84532
|
||||
```
|
||||
|
||||
@@ -40,12 +40,6 @@ networks: {
|
||||
accounts: [process.env.PRIVATE_KEY as string],
|
||||
gasPrice: 1000000000,
|
||||
},
|
||||
// for testnet
|
||||
"base-goerli": {
|
||||
url: "https://goerli.base.org",
|
||||
accounts: [process.env.PRIVATE_KEY as string],
|
||||
gasPrice: 1000000000,
|
||||
},
|
||||
// for Sepolia testnet
|
||||
"base-sepolia": {
|
||||
url: "https://sepolia.base.org",
|
||||
|
||||
@@ -21,7 +21,7 @@ keywords:
|
||||
|
||||
:::info
|
||||
|
||||
Viem is currently only available on Base Goerli testnet.
|
||||
Viem is currently only available on Base Sepolia testnet.
|
||||
|
||||
:::
|
||||
|
||||
@@ -57,7 +57,7 @@ const client = createPublicClient({
|
||||
|
||||
To use Base, you must specify `base` as the chain when creating a Client.
|
||||
|
||||
To use Base Goerli (testnet), replace `base` with `baseGoerli`.
|
||||
To use Base Sepolia (testnet), replace `base` with `baseSepolia`.
|
||||
|
||||
:::
|
||||
|
||||
@@ -99,7 +99,7 @@ client.sendTransaction({ ... })
|
||||
|
||||
In addition to making a JSON-RPC request (`eth_requestAccounts`) to get an Account, viem provides various helper methods for creating an `Account`, including: [`privateKeyToAccount`](https://viem.sh/docs/accounts/privateKey.html), [`mnemonicToAccount`](https://viem.sh/docs/accounts/mnemonic.html), and [`hdKeyToAccount`](https://viem.sh/docs/accounts/hd.html).
|
||||
|
||||
To use Base Goerli (testnet), replace `base` with `baseGoerli`.
|
||||
To use Base Sepolia (testnet), replace `base` with `baseSepolia`.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ const web3 = new Web3('https://mainnet.base.org');
|
||||
|
||||
:::info
|
||||
|
||||
To alternatively connect to Base Goerli (testnet), change the above URL from `https://mainnet.base.org` to `https://goerli.base.org`.
|
||||
To alternatively connect to Base Sepolia (testnet), change the above URL from `https://mainnet.base.org` to `https://sepolia.base.org`.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
Reference in New Issue
Block a user