Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Remove local node mentions #9

Merged
merged 1 commit into from
Apr 5, 2024
Merged
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
118 changes: 14 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,42 +66,28 @@ You can edit the CI script in [.github/workflows/ci.yml](./.github/workflows/ci.

### Pre Requisites

Install [docker](https://docs.docker.com/engine/install/)

Install [pnpm](https://pnpm.io/installation)

Before being able to run any command, you need to create a `.env` file and set a BIP-39 compatible mnemonic as an
environment variable. You can follow the example in `.env.example`. If you don't already have a mnemonic, you can use
this [website](https://iancoleman.io/bip39/) to generate one.

Then, proceed with installing dependencies:
environment variable. If you don't already have a mnemonic, you can use this [website](https://iancoleman.io/bip39/) to
generate one. You can run the following command to use the example .env:

```sh
pnpm install
cp .env.example .env
```

### Start fhevm

Start a local fhevm docker container that inlcudes everything needed to deploy FHE encrypted smart contracts

```sh
# In one terminal, keep it opened
# The node logs are printed
pnpm fhevm:start
```

To stop:
Then, proceed with installing dependencies:

```sh
pnpm fhevm:stop
pnpm install
```

### Compile

Compile the smart contracts with Hardhat:

```sh
pnpm compile
npx hardhat compile --network inco
```

### TypeChain
Expand All @@ -112,78 +98,31 @@ Compile the smart contracts and generate TypeChain bindings:
pnpm typechain
```

### List accounts

From the mnemonic in .env file, list all the derived Ethereum adresses:

```sh
pnpm task:accounts
```

### Get some native coins

In order to interact with the blockchain, one need some coins. This command will give coins to the first address derived
from the mnemonic in .env file.

```sh
pnpm fhevm:faucet
```

<br />
<details>
<summary>To get the first derived address from mnemonic</summary>
<br />

```sh
pnpm task:getEthereumAddress
```

</details>
<br />

### Deploy

Deploy the ERC20 to local network:
Deploy the ERC20 to Inco Gentry Testnet Network:

```sh
pnpm deploy:contracts
npx hardhat deploy --network inco
```

Notes: <br />

<details>
<summary>Error: cannot get the transaction for EncryptedERC20's previous deployment</summary>

One can delete the local folder in deployments:

```bash
rm -r deployments/local/
```

</details>

<details>
<summary>Info: by default, the local network is used</summary>

One can change the network, check [hardhat config file](./hardhat.config.ts).

</details>
<br />

#### Mint

Run the `mint` task on the local network:
Run the `mint` task on the Inco Gentry Testnet Network:

```sh
pnpm task:mint --network local --mint 1000 --account alice
npx hardhat task:mint --mint [AMOUNT] --account [alice|bob|carol|dave] --network inco
```

(For more control over the deployment process, you can rewrite the deployment script (deploy.ts) and use the command
`npx hardhat run scripts/deploy.ts --network inco` to deploy your contracts.)

### Test

Run the tests with Hardhat:

```sh
pnpm test
npx hardhat test --network inco
```

### Lint Solidity
Expand Down Expand Up @@ -238,31 +177,6 @@ pnpm task:deployERC20

## Tips

### Increase gas limit

If you are running several fhe operations and need to have more gas per block, here is a way to customize your local
node setup.

1. Copy docker setup.sh file

```bash
docker cp fhevm:/config/setup.sh .
```

2. Increase the gas limit from 10M to 100M for example in setup.sh

```bash
cat $HOME_EVMOSD/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME_EVMOSD/config/tmp_genesis.json && mv $HOME_EVMOSD/config/tmp_genesis.json $HOME_EVMOSD/config/genesis.json
```

3. Run the dev image with the custom setup.sh file

```bash
docker run -i -v $PWD/setup.sh:/config/setup.sh -p 8545:8545 --rm --name fhevm docker.io/inconetwork/inco-chain:0.1.9.1-hardhat-template
```

Note: one can also replace fhevm:start in package.json with the above command

### Syntax Highlighting

If you use VSCode, you can get Solidity syntax highlighting with the
Expand All @@ -275,10 +189,6 @@ If you use VSCode, you can get Solidity syntax highlighting with the
To view the coverage report generated by `pnpm coverage`, just click `Go Live` from the status bar to turn the server
on/off.

## Local development with Docker

Please check Evmos repository to be able to build FhEVM from sources.

## License

This project is licensed under MIT.
10 changes: 1 addition & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,7 @@
"task:getEthereumAddress": "hardhat task:getEthereumAddress",
"task:mint": "hardhat task:mint",
"task:deployERC20": "hardhat task:deployERC20",
"task:accounts": "hardhat task:accounts",
"fhevm:start": "docker run -i -p 8545:8545 --rm --name fhevm docker.io/inconetwork/inco-chain:0.1.9.1-hardhat-template",
"fhevm:stop": "docker rm -f fhevm",
"fhevm:restart": "fhevm:stop && fhevm:start",
"fhevm:faucet": "npm run fhevm:faucet:alice && sleep 5 && npm run fhevm:faucet:bob && sleep 5 && npm run fhevm:faucet:carol && sleep 5 && npm run fhevm:faucet:dave",
"fhevm:faucet:alice": "docker exec -i fhevm go run /go/src/github.com/evmos/evmos/faucet.go $(npx hardhat task:getEthereumAddressAlice)",
"fhevm:faucet:bob": "docker exec -i fhevm go run /go/src/github.com/evmos/evmos/faucet.go $(npx hardhat task:getEthereumAddressBob)",
"fhevm:faucet:carol": "docker exec -i fhevm go run /go/src/github.com/evmos/evmos/faucet.go $(npx hardhat task:getEthereumAddressCarol)",
"fhevm:faucet:dave": "docker exec -i fhevm go run /go/src/github.com/evmos/evmos/faucet.go $(npx hardhat task:getEthereumAddressDave)"
"task:accounts": "hardhat task:accounts"
},
"dependencies": {
"@openzeppelin/contracts": "^4.9.2"
Expand Down
Loading