forked from celo-org/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create pages * add content * placeholder images * add using-mac.md * add deploy-remix.md * add deploy replit * update bad img link * fix broken link * add new files to sidebar * Deploy on Celo Updates Create remaining Deploy on Celo files, added images, fixed links, some sidebar updates for related pages. * create deploy-truffle * update shell command format * remove step numbers * remove steps * Update sidebar & remove steps Took testnet wallet out of local env and removed "steps" from deploy dapp pages * remove steps, update config * add example repo * replace 'secret' with 'env' * missing . * add sourcify plugin info Co-authored-by: Joe Nyzio <[email protected]>
- Loading branch information
1 parent
5288823
commit f37902d
Showing
40 changed files
with
1,197 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: Deploy a DApp on Celo | ||
description: Quick introductions on how to deploy dApps on Celo using Remix, Truffle, and Hardhat. | ||
--- | ||
|
||
# Deploy a DApp on Celo | ||
|
||
Quick introductions on how to deploy dApps on Celo using Remix, Truffle, and Hardhat. | ||
|
||
____ | ||
|
||
Deploying a dApp on Celo is a quick and simple process. You can deploy on Celo using any [Ethereum](https://ethereum.org/en/) compatible tools including Remix, Truffle, Hardhat, and others. By making a few adjustments to your project’s network configuration settings, you can deploy your new or existing dApp on Celo. | ||
|
||
## Start Building on Celo | ||
|
||
The fastest way to deploy a dApp on Celo is to [Set up a Testnet Development Wallet](./testnet-wallet.md) and [Deploy with Remix](./deploy-remix.md). This doesn’t require installing anything on your local device and gives you access to powerful web-based tools for dApp development. Alternatively, you can set up a local development environment and deploy using many popular dApp deployment tools. | ||
|
||
## Set up your local environment | ||
|
||
- [Using Mac](./using-mac.md) | ||
- [Using Windows](/developer-guide/start/develop-on-windows) | ||
|
||
## Set up a development wallet | ||
|
||
- [Set up a Testnet Development Wallet](./testnet-wallet.md) | ||
|
||
## Choose your preferred tool to get started | ||
|
||
- [Deploy with Remix](./deploy-remix.md) | ||
- [Deploy with Truffle](./deploy-truffle.md) | ||
- [Deploy with Hardhat](./deploy-hardhat) | ||
- [Deploy with Replit](./deploy-replit.md) | ||
|
||
These guides are meant to help you deploy a dApp on Celo as quickly as possible. Read the supporting resources linked throughout each guide for an in-depth look at the tools and code. If you would like to learn more about Solidity (the language for developing smart contracts) you can view the [Solidity docs](https://docs.soliditylang.org/en/latest/) or with [Solidity by Example](https://solidity-by-example.org/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
--- | ||
title: Deploy with Hardhat | ||
description: How to deploy a Smart Contract to Celo using Hardhat | ||
--- | ||
|
||
# Deploy on Celo with Hardhat | ||
|
||
How to deploy a smart contract to Celo testnet, mainnet, or a local network using [Hardhat](https://hardhat.org/). | ||
|
||
--- | ||
|
||
[Hardhat](https://hardhat.org/) is a development environment to compile, deploy, test, and debug your Ethereum or Celo software. It helps developers manage and automate the recurring tasks that are inherent to the process of building smart contracts and dApps, as well as easily introducing more functionality around this workflow. This means compiling, running, and testing smart contracts at the very core. | ||
|
||
## Prerequisites | ||
|
||
To deploy on Celo using Hardhat, you should have Celo set up Celo in your local environment. If you prefer to deploy without a local environment, you can deploy using Remix or Replit. | ||
|
||
* [Using Windows](./develop-on-windows.md) | ||
* [Using Mac](./using-mac.md) | ||
|
||
## Create Hardhat Project | ||
|
||
Choose one of the following items to prepare a dApp to deploy on Celo. | ||
|
||
* Follow the [installation instructions and quickstart](https://hardhat.org/getting-started/#installation) to build and deploy your smart contract. | ||
|
||
## Update the hardhat.config.js file | ||
|
||
Open [hardhat-config.js](https://hardhat.org/config/) in a text editor and replace its contents with this [Celo configuration code](https://github.com/celo-org/DevRel/blob/main/configuration/hardhat.config.js). This code is similar to Hardhat settings with a few configuration updates needed to deploy to a Celo network. | ||
|
||
### Connect to Local Network | ||
|
||
Using Celo Ganache CLI creates test accounts at the localhost on port 7545. The private network setup connects to your localhost on this port and gives you access to your accounts on ganache-cli. | ||
|
||
``` | ||
localhost: { | ||
url: "http://127.0.0.1:7545" | ||
}, | ||
``` | ||
|
||
:::tip | ||
|
||
If you choose to [Set up a Local Development Chain](./walkthroughs/development-chain.md), your blockchain will also be hosted on a private network on localhost. This same configuration can be used to connect to the local development chain. | ||
|
||
::: | ||
|
||
### Connect to Testnet using Forno | ||
|
||
Using [Forno](./forno/index.md) allows you to connect to the Celo test blockchain without running a local node. The testnet configuration uses Forno to connect you to the Celo Testnet (Alfajores) using HDWalletProvider and the mnemonic stored in your **.env** file. | ||
|
||
``` | ||
alfajores: { | ||
url: "https://alfajores-forno.celo-testnet.org", | ||
accounts: { | ||
mnemonic: process.env.MNEMONIC, | ||
path: "m/44'/52752'/0'/0" | ||
}, | ||
chainId: 44787 | ||
} | ||
``` | ||
|
||
:::note | ||
|
||
Celo uses a different account derivation path than Ethereum, so you have to specify "m/44'/52752'/0'/0" as the path. | ||
|
||
::: | ||
|
||
### Connect to Mainnet using Forno | ||
|
||
Using [Forno](./forno/index.md) also allows you to connect to the Celo main blockchain without running a local node. The mainnet configuration uses Forno to connect you to the Celo Mainnet using HDWalletProvider and the mnemonic stored in your **.env** file. | ||
|
||
``` | ||
celo: { | ||
url: "https://forno.celo.org", | ||
accounts: { | ||
mnemonic: process.env.MNEMONIC, | ||
path: "m/44'/52752'/0'/0" | ||
}, | ||
chainId: 42220 | ||
} | ||
``` | ||
|
||
:::tip | ||
|
||
[Forno](./forno/index.md) is a cLabs hosted node service for interacting with the Celo network. This allows you to connect to the Celo Blockchain without having to run your own node. | ||
|
||
::: | ||
|
||
## Deploy to Celo | ||
|
||
Run the following command from your root project directory to deploy to Celo Alfajores testnet. | ||
|
||
``` | ||
npx hardhat run scripts/sample-script.js --network alfajores | ||
``` | ||
...or run this command to deploy to Celo mainnet. | ||
|
||
``` | ||
npx hardhat run scripts/sample-script.js --network celo | ||
``` | ||
|
||
## View Contract Deployment | ||
|
||
Copy your **contract address** from the terminal and navigate to the [block explorer](https://explorer.celo.org/) to search for your deployed contract. Switch between networks to find your contract using the dropdown by the search bar. | ||
|
||
|
||
![github](/img/doc-images/deploy-hardhat/image1.png) | ||
|
||
|
||
:::tip | ||
|
||
Learn more about building and deploying dApps using the <a href="https://hardhat.org/">HardHat documentation</a>. | ||
|
||
::: | ||
|
||
## Verify Smart Contract | ||
|
||
### Using Blockscout | ||
|
||
Verifying a smart contract allows developers to review your code from within the Celo Block Explorer. | ||
|
||
* Navigate to the Code tab at the Explorer page for your contract's address | ||
* Click Verify & Publish to enter the smart contract verification page | ||
|
||
![github](/img/doc-images/deploy-hardhat/image2.png) | ||
|
||
* Upload your smart contract (example: HelloCelo.sol) and it’s .json file (example: HelloCelo.json) found in **build > contracts** folder. | ||
|
||
![github](/img/doc-images/deploy-hardhat/image3.png) | ||
|
||
* Click **Verify & Publish** | ||
* Navigate to the **Contract Address Details Page** in the block explore to, use the **Code**, **Read Contract**, and **Write Contract** panels to view and interact with your deployed smart contract. | ||
|
||
### Using the hardhat plugin | ||
|
||
You can also verify your contracts programatically using the [hardhat-deploy plugin](https://hardhat.org/plugins/hardhat-deploy.html). | ||
|
||
First, install the plugin in your project with | ||
|
||
```shell | ||
npm install -D hardhat-deploy | ||
``` | ||
|
||
then add the following line to your `hardhat.config.js` file. | ||
|
||
```js | ||
require('hardhat-deploy'); | ||
``` | ||
|
||
Now you can verify your contracts on sourcify and Blockscout with | ||
|
||
```shell | ||
hardhat --network alfajores sourcify | ||
``` | ||
|
||
just be sure to replace the network flag with the appropriate network. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
title: Deploy with Remix | ||
description: How to deploy a Smart Contract to Celo using remix.ethereum.org. | ||
--- | ||
|
||
# Deploy on Celo with Remix | ||
|
||
How to deploy a smart contract to Celo testnet, mainnet, or a local network using [Remix](https://remix.ethereum.org/). | ||
|
||
____ | ||
|
||
The [Remix IDE](https://remix-project.org/) is an open-source web and desktop application for creating and deploying Smart Contracts. Originally created for Ethereum, it fosters a fast development cycle and has a rich set of plugins with intuitive GUIs. Remix is used for the entire journey of contract development and is a playground for learning and teaching Celo. | ||
|
||
In this guide, you will learn to deploy a smart contract on Celo using [remix.ethereum.org](http://remix.ethereum.org). | ||
|
||
:::tip | ||
|
||
To learn more about the features available to you as a smart contract developer with Remix, visit the [Remix documentation](https://remix-ide.readthedocs.io/en/latest/). | ||
|
||
::: | ||
|
||
## Create a Smart Contract | ||
|
||
* Navigate to [remix.ethereum.org](http://remix.ethereum.org) and select **contracts > 1_Storage.sol** from the **File Explorers** pane. | ||
* Review the smart contract code and learn more using the [Solidity docs](https://docs.soliditylang.org/en/latest/) or with [Solidity by Example](https://solidity-by-example.org/). | ||
* Complete any changes to your smart contract and save the final version (Command/Ctrl + S). | ||
|
||
![github](/img/doc-images/deploy-remix/image1.png) | ||
|
||
## Compile the Contract | ||
|
||
* Choose the **Solidity Compiler Icon** on the left side menu. | ||
* Check that your compiler version is within the versions specified in the **pragma solidity statement**. | ||
* Select the **Compile** button to compile your smart contract. | ||
|
||
![github](/img/doc-images/deploy-remix/image2.png) | ||
|
||
## Deploy the Contract | ||
|
||
* Click the **Deploy and Run Transactions Icon** on the left side menu. | ||
* Choose **Injected Web3** as your environment. | ||
* [Connect MetaMask to Celo](/getting-started/wallets/using-metamask-with-celo) testnet and verify that the environment reads: | ||
* **Custom (44787) network** for Celo testnet | ||
* **Custom (42220) network** for Celo mainnet | ||
* Click **Deploy** and select **Confirm** in the MetaMask notification window to pay for the transaction | ||
|
||
![github](/img/doc-images/deploy-remix/image3.png) | ||
|
||
## Interacting with the Contract | ||
|
||
* Select the **dropdown** on the newly deployed contract at the bottom of the left panel. | ||
* View the deployed contract’s functions using the **Deployed Contracts** window. | ||
* Select functions to read or write on the Celo testnet using the function inputs as needed. | ||
* Confirm write transactions in the **MetaMask Notification Window** to pay the transaction’s gas fee. | ||
|
||
![github](/img/doc-images/deploy-remix/image4.png) | ||
|
||
## View Contract Details | ||
|
||
* Copy the contract address from the **Deployed Contracts** window on the left panel. | ||
* Navigate to the [Celo Block Explorer](https://explorer.celo.org/) and use the contract address to search for your contract. | ||
* Explore the details of your deployed smart contract and learn more about the explorer [here](http://docs.blockscout.com). | ||
|
||
![github](/img/doc-images/deploy-remix/image6.png) | ||
|
||
## Verify the Smart Contract | ||
|
||
* Verifying a smart contract allows anyone to review your code from within the Celo Block Explorer. This can be done using the Remix Sourcify Plugin. | ||
* Navigate back to the **Remix IDE**, select **Plugin Manager** from the left side menu. | ||
* Search for **Sourcify**, click Activate, and open the newly installed **Sourcify Plugin**. | ||
* Choose Verifier, select the dropdown menu, and choose the location for your deployed contract (example **Celo (Alfajores)**). | ||
* Paste your contract address into the **Contract Address** field and select **Verify**. | ||
|
||
:::tip | ||
|
||
The source code of the contract that you are verifying will need to be in Remix. Contracts deployed with Truffle, Hardhat, and other tools can also be verified using the Remix Sourcify plugin, but you will need to copy your contract source code into Remix first. | ||
|
||
::: | ||
|
||
![github](/img/doc-images/deploy-remix/image5.png) | ||
|
||
* Navigate to the **Contract Address Details Page** in the block explore to, use the **Code, Read Contract**, and **Write Contract** panels to view and interact with your deployed smart contract. |
Oops, something went wrong.