Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
node_modules
.env
packages/*/.env
packages/*/.env.*

# IntelliJ project files
*.iml
*.ipr
*.iws
.idea

*.gitkeep

# eclipse project file
.settings/
.classpath
.project

# NetBeans specific
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# OS
.DS_Store

# Miscellaneous
*.class
*.log
*.pyc
*.swp

PROPOSAL.md
12 changes: 12 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Settings in the [build] context are global and are applied to
# all contexts unless otherwise overridden by more specific contexts.
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
# If not set, defaults to the root directory.
base = "/"
publish = "packages/react-app/.next"
command = "yarn build-ui"

[[plugins]]
package = "@netlify/plugin-nextjs"
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "Celo-OnchainNFT-Dapp",
"version": "1.0.0",
"description": "Custom Celo Composer project.",
"private": true,
"author": "Celo",
"license": "MIT",
"scripts": {
"react-app:dev": "yarn workspace @Celo-Auction-DApp/react-app dev",
"react-app:build": "yarn workspace @Celo-Auction-DApp/react-app build",
"react-app:start": "yarn workspace @Celo-Auction-DApp/react-app start",
"react-app:lint": "yarn workspace @Celo-Auction-DApp/react-app lint",
"hardhat:test": "yarn workspace @Celo-Auction-DApp/hardhat test",
"hardhat:test-local": "yarn workspace @Celo-Auction-DApp/hardhat test-local",
"hardhat:accounts": "yarn workspace @Celo-Auction-DApp/hardhat accounts",
"hardhat:devchain": "yarn workspace @Celo-Auction-DApp/hardhat devchain",
"hardhat:deploy": "yarn workspace @Celo-Auction-DApp/hardhat deploy",
"hardhat:deploy-reset-watch": "yarn workspace @Celo-Auction-DApp/hardhat deploy-reset-watch",
"hardhat:watch": "yarn workspace @Celo-Auction-DApp/hardhat watch",
"hardhat:fork-mainnet": "yarn workspace @Celo-Auction-DApp/hardhat fork-mainnet"
},
"repository": {
"type": "git",
"url": "git+https://github.com/celo-org/celo-composer.git"
},
"bugs": {
"url": "https://github.com/celo-org/celo-composer/issues"
},
"homepage": "https://github.com/celo-org/celo-composer/blob/main/README.md",
"workspaces": [
"packages/*"
],
"keywords": [
"celo-composer",
"celo"
]
}
3 changes: 3 additions & 0 deletions packages/hardhat/.envexample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MNEMONIC=""
PRIVATE_KEY=""
CELOSCAN_API_KEY=""
13 changes: 13 additions & 0 deletions packages/hardhat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
.env
coverage
coverage.json
typechain

#Hardhat files
cache
artifacts
deployments

# hardhat typechain generated files
types/
1 change: 1 addition & 0 deletions packages/hardhat/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
124 changes: 124 additions & 0 deletions packages/hardhat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Hardhat | Celo Composer

This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts.

## Setup & Installation

### Alfajores Testnet Setup

**Note** This setup is not required when using a local development blockchain (like celo-devchain or Ganache).

1. Create a `.env` file similar to `.envexample`.
2. Paste the private key in `.env`.
> note: depending on how you generate your private key, you may have to prepend `0x` in the private key does not already have it prepended.
3. Faucet your account with the Alfajores testnet faucet [here](https://celo.org/developers/faucet).

## Develop

1. Write your contracts in `./contracts`.
2. Update contract deployment scripts in `./deploy`.
3. Deploy contracts with `yarn deploy` from the **root directory**. Optionally add the reset flag (`yarn deploy --reset`) to overwrite previous deployment info. The default deployment network is specified in `hardhat.config.js` and is set to `alfajores` initially. You can also overwrite previous deployments and redeploy when there are changes to the deployment script or contracts automatically by running `yarn deploy-reset-watch`. You can specify a specific network deployment directly with

```bash
npx hardhat deploy --network [network name]
```

Network configs are defined in `hardhat.config.js`.

## [Celo devchain](https://github.com/terminal-fi/celo-devchain)

Run a local development Celo chain with `yarn devchain` in the `packages/hardhat` folder. You can print the addresses of the [Celo protocol contracts](https://github.com/celo-org/celo-monorepo/tree/master/packages/protocol) with `npx @terminal-fi/celo-devchain --test`.

This is a version of Ganache (@celo/ganache-cli) that deploys the Celo core protocol contracts when it starts.

**NOTE:** @celo/ganache-cli works only with Node 10 or Node 12 versions. Using Node 14 or later will result in errors.

**NOTE:** @celo/ganache-cli currently doesn't support locally signed transactions. If you send a locally signed transaction it will throw: Error: Number can only safely store up to 53 bits error and crash. Thus you have to make sure your ContractKit doesn't actually have the private keys for test addresses and send transactions to be signed by ganache-cli itself.

### Start

```bash
npx celo-devchain --port 8545
```

or

```bash
yarn devchain
```

### Generate Typescript bindings

This setting defaults to the web3 v1 bindings because that is what is used by use-contractkit in `packages/react-app`.

You can change the output directory and target in `hardhat.config.js`.

```bash
npx hardhat typechain
```

Read more about Typechain [here](https://github.com/dethcrypto/TypeChain) and more about the hardhat plugin [here](https://github.com/dethcrypto/TypeChain/tree/master/packages/hardhat).

### Run sanity tests and print all core contract addresses

```bash
npx @terminal-fi/celo-devchain --test
```

## Fork mainnet with [Ganache](https://trufflesuite.com/blog/introducing-ganache-7/index.html#1-zero-config-mainnet-forking)

You can get a local copy of mainnet by forking with Ganache. Learn more about [forking mainnet with Ganache here.](https://trufflesuite.com/blog/introducing-ganache-7/index.html#1-zero-config-mainnet-forking)

There is a script provided (`yarn fork-mainnet`) to fork mainnet and fund the same test accounts that come with Celo devchain. Sometimes sending transactions from the first account (which defaults to `0x5409ED021D9299bf6814279A6A1411A7e866A631`) is delayed and sending test transactions from the other accounts works better for some reason. :shrug: The private keys of the associated test accounts are printed in `account_keys.json`.

## Verify your contracts

### hardhat-celo

You can easily verify your contracts deployed to the associated networks with hardhat-celo.

[Reference](https://docs.celo.org/developer/verify/hardhat)

```bash
npx hardhat verify smart-contract-address parameter(s) --network alfajores
```

On Mainnet:

```bash
npx hardhat verify smart-contract-address parameter(s) --network celo
```

### Sourcify

Additionally, you can easily verify your contracts deployed to the associated networks with the following commands.

[Reference](https://docs.celo.org/blog/hardhat-deploy-verify)

On Alfajores:

```bash
npx hardhat --network alfajores sourcify
```

On Mainnet:

```bash
npx hardhat --network celo sourcify
```

## Deploy with [Figment Datahub](https://datahub.figment.io/)

Figment Datahub provides RPC & REST APIs for Celo network. To learn more about Datahub refer this doc - [https://docs.figment.io/introduction/what-is-datahub](https://docs.figment.io/introduction/what-is-datahub). Follow these steps to deploy your smart contract with Figment datahub's RPC.

- Create account on [Datahub](https://datahub.figment.io/).
- On the dashboard, click on `Create new app` and select **Celo** from the protocol list.
- Once you have created an app, copy the api key.
- Edit `hardhat.config.js` and update `alfajoresDatahub` and `celoDatahub` with the API Key.
- Run the test or deploy the contract with following commands.

```bash
npx hardhat run scripts/run.ts --network alfajoresDatahub

npx hardhat run scripts/deploy.ts --network celoDatahub
```
1 change: 1 addition & 0 deletions packages/hardhat/account_keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"addresses":{"0x5409ed021d9299bf6814279a6a1411a7e866a631":"0x5409ed021d9299bf6814279a6a1411a7e866a631","0x6ecbe1db9ef729cbe972c83fb886247691fb6beb":"0x6ecbe1db9ef729cbe972c83fb886247691fb6beb","0xe36ea790bc9d7ab70c55260c66d52b1eca985f84":"0xe36ea790bc9d7ab70c55260c66d52b1eca985f84","0xe834ec434daba538cd1b9fe1582052b880bd7e63":"0xe834ec434daba538cd1b9fe1582052b880bd7e63","0x78dc5d2d739606d31509c31d654056a45185ecb6":"0x78dc5d2d739606d31509c31d654056a45185ecb6","0xa8dda8d7f5310e4a9e24f8eba77e091ac264f872":"0xa8dda8d7f5310e4a9e24f8eba77e091ac264f872","0x06cef8e666768cc40cc78cf93d9611019ddcb628":"0x06cef8e666768cc40cc78cf93d9611019ddcb628","0x4404ac8bd8f9618d27ad2f1485aa1b2cfd82482d":"0x4404ac8bd8f9618d27ad2f1485aa1b2cfd82482d","0x7457d5e02197480db681d3fdf256c7aca21bdc12":"0x7457d5e02197480db681d3fdf256c7aca21bdc12","0x91c987bf62d25945db517bdaa840a6c661374402":"0x91c987bf62d25945db517bdaa840a6c661374402"},"private_keys":{"0x5409ed021d9299bf6814279a6a1411a7e866a631":"0xf2f48ee19680706196e2e339e5da3491186e0c4c5030670656b0e0164837257d","0x6ecbe1db9ef729cbe972c83fb886247691fb6beb":"0x5d862464fe9303452126c8bc94274b8c5f9874cbd219789b3eb2128075a76f72","0xe36ea790bc9d7ab70c55260c66d52b1eca985f84":"0xdf02719c4df8b9b8ac7f551fcb5d9ef48fa27eef7a66453879f4d8fdc6e78fb1","0xe834ec434daba538cd1b9fe1582052b880bd7e63":"0xff12e391b79415e941a94de3bf3a9aee577aed0731e297d5cfa0b8a1e02fa1d0","0x78dc5d2d739606d31509c31d654056a45185ecb6":"0x752dd9cf65e68cfaba7d60225cbdbc1f4729dd5e5507def72815ed0d8abc6249","0xa8dda8d7f5310e4a9e24f8eba77e091ac264f872":"0xefb595a0178eb79a8df953f87c5148402a224cdf725e88c0146727c6aceadccd","0x06cef8e666768cc40cc78cf93d9611019ddcb628":"0x83c6d2cc5ddcf9711a6d59b417dc20eb48afd58d45290099e5987e3d768f328f","0x4404ac8bd8f9618d27ad2f1485aa1b2cfd82482d":"0xbb2d3f7c9583780a7d3904a2f55d792707c345f21de1bacb2d389934d82796b2","0x7457d5e02197480db681d3fdf256c7aca21bdc12":"0xb2fd4d29c1390b71b8795ae81196bfd60293adf99f9d32a0aff06288fcdac55f","0x91c987bf62d25945db517bdaa840a6c661374402":"0x23cb7121166b9a2f93ae0b7c05bde02eae50d64449b2cbb42bc84e9d38d6cc89"}}
Loading