Skip to content

Commit

Permalink
Some more updates - added remix plugin docs & Gitpod info. Also gener…
Browse files Browse the repository at this point in the history
…al cleanups
  • Loading branch information
Cashmaney committed Feb 4, 2024
1 parent f0a88cf commit e6a72ef
Show file tree
Hide file tree
Showing 24 changed files with 507 additions and 219 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Permits & Access Control
# 🫷 Permits & Access Control

In a Fully Homomorphic Encryption (FHE) context, data stored in the contract's storage is encrypted.
Therefore, granting selective access to data becomes an essential part of access control.
Expand Down
76 changes: 50 additions & 26 deletions docs/devdocs/Examples and References/Examples-fheDapps.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,76 @@ Here you can find a list of some of cool apps that you can use as a reference
<table>
<thead>
<tr>
<th width="222.33333333333331">App</th>
<th width="333">Repo</th>
<th>App</th>
<th>Repo</th>
<th>UI</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fhevm Examples</td>
<td><a href="https://github.com/zama-ai/fhevm-solidity/tree/main/examples">https://github.com/zama-ai/fhevm-solidity/tree/main/examples</a></td>
<td><a href="https://dapps.zama.ai/">https://dapps.zama.ai/</a><br /><a href="http://fhenix-demo.pages.dev/">http://fhenix-demo.pages.dev/</a></td>
<td>This examples will need to be updated when using Fhenix's FHE.sol</td>
</tr>
<tr>
<td>Wrapped ERC20</td>
<td><a href="https://github.com/FhenixProtocol/werc20-example">https://github.com/FhenixProtocol/werc20-example</a><br /></td>
<td></td>
<td>FHERC-20</td>
<td><a href="https://github.com/FhenixProtocol/example-contracts/blob/master/wrapping-ERC20/WrappingERC20.sol">View on Github</a><br /></td>
<td><a href="http://fhenix-demo.pages.dev/">FHERC-20 Demo</a></td>
<td></td>
</tr>
<tr>
<td>Blind Auction</td>
<td><a href="https://www.fhenix.io">TO BE ADDED</a></td>
<td><a href="https://www.fhenix.io">TO BE ADDED</a></td>
<td></td>
<td></td>
<td></td>
</tr>

[//]: # (<tr>)

[//]: # (<td>NFT + 128 bit key</td>)

[//]: # (<td><a href="https://github.com/FhenixProtocol/devnet-contracts/blob/main/ERC721WithKey.sol">https://github.com/FhenixProtocol/devnet-contracts/blob/main/ERC721WithKey.sol</a></td>)

[//]: # (<td></td>)

[//]: # (<td>This examples will need to be updated when using Fhenix's FHE.sol</td>)

[//]: # (</tr>)
<tr>
<td>NFT + 128 bit key</td>
<td><a href="https://github.com/FhenixProtocol/devnet-contracts/blob/main/ERC721WithKey.sol">https://github.com/FhenixProtocol/devnet-contracts/blob/main/ERC721WithKey.sol</a></td>
<td>Confidential Voting</td>
<td><a href="https://github.com/FhenixProtocol/confidential-voting">View on Github</a></td>
<td></td>
<td></td>
<td>This examples will need to be updated when using Fhenix's FHE.sol</td>
</tr>
<tr>
<td>Confidential Voting</td>
<td><a href="https://github.com/FhenixProtocol/confidential-voting">https://github.com/FhenixProtocol/confidential-voting</a></td>
<td>Simple Lottery</td>
<td><a href="https://github.com/FhenixProtocol/example-contracts/blob/master/lottery/Lottery.sol">View on Github</a></td>
<td></td>
<td></td>
</tr>
<tr>
<td>NFT Event Ticket</td>
<td><a href="https://github.com/FhenixProtocol/ticketing-contracts">https://github.com/FhenixProtocol/ticketing-contracts</a><a href="https://github.com/FhenixProtocol/ticket-verifier">https://github.com/FhenixProtocol/ticket-verifier</a></td>
<td><a href="https://ticket-manager.pages.dev/">https://ticket-manager.pages.dev/</a><a href="https://ticket-manager.pages.dev/?verifier=1">https://ticket-manager.pages.dev/?verifier=1</a></td>
<td>This examples will need to be updated when using Fhenix's FHE.sol</td>
<td>FHE.sol Operation Examples</td>
<td><a href="https://github.com/FhenixProtocol/fheos/tree/master/solidity/tests/contracts">https://github.com/FhenixProtocol/fheos/tree/master/solidity/tests/contracts</a></td>
<td><a href="https://github.com/FhenixProtocol/fheos/blob/master/solidity/tests/precompiles.test.ts">https://github.com/FhenixProtocol/fheos/blob/master/solidity/tests/precompiles.test.ts</a></td>
<td>The UI link is for a javascript interface that uses hardhat in order to interact with the contracts</td>
<td>Fhevm Examples</td>
<td><a href="https://github.com/zama-ai/fhevm-solidity/tree/main/examples">View on Github</a></td>
<td><a href="https://dapps.zama.ai/">https://dapps.zama.ai/</a><br /></td>
<td>NOTE: These examples are not directly compatible with Fhenix and must be adapted</td>
</tr>


[//]: # (<tr>)

[//]: # (<td>NFT Event Ticket</td>)

[//]: # (<td><a href="https://github.com/FhenixProtocol/ticketing-contracts">https://github.com/FhenixProtocol/ticketing-contracts</a>)

[//]: # (<a href="https://github.com/FhenixProtocol/ticket-verifier">https://github.com/FhenixProtocol/ticket-verifier</a></td>)

[//]: # (<td><a href="https://ticket-manager.pages.dev/">https://ticket-manager.pages.dev/</a><a href="https://ticket-manager.pages.dev/?verifier=1">https://ticket-manager.pages.dev/?verifier=1</a></td>)

[//]: # (<td>This examples will need to be updated when using Fhenix's FHE.sol</td>)
[//]: # (<td>FHE.sol Operation Examples</td>)

[//]: # (<td><a href="https://github.com/FhenixProtocol/fheos/tree/master/solidity/tests/contracts">https://github.com/FhenixProtocol/fheos/tree/master/solidity/tests/contracts</a></td>)

[//]: # (<td><a href="https://github.com/FhenixProtocol/fheos/blob/master/solidity/tests/precompiles.test.ts">https://github.com/FhenixProtocol/fheos/blob/master/solidity/tests/precompiles.test.ts</a></td>)

[//]: # (<td>The UI link is for a javascript interface that uses hardhat in order to interact with the contracts</td>)

[//]: # (</tr>)
</tbody>
</table>
55 changes: 53 additions & 2 deletions docs/devdocs/Setting Up Your Environment/Gitpod.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
sidebar_position: 3
title: Gitpod
title: ☁️ Gitpod
---

import GitPodLogo from '@site/static/img/gitpod-logo.svg';
Expand All @@ -10,4 +10,55 @@ import GitPodLogo from '@site/static/img/gitpod-logo.svg';

If you're more of a cloud-based developer, you can skip all the installation steps and work directly with our Gitpod environment. This environment includes a LocalFhenix instance and all the tools you need to dive in.

You can run an instance of LocalFhenix in Gitpod by [clicking here](https://gitpod.io/#https://github.com/fhenixprotocol/hardhat-template) (or directly from the hardhat-template repo)
## Usage

You can run an instance of LocalFhenix in Gitpod by [clicking here](https://gitpod.io/#https://github.com/fhenixprotocol/fhenix-hardhat-example).

After opening the the Gitpod container and starting up the instance, you will be greeted with the following terminal:

![](/img/gitpod-ss1.png)

Please wait for about 60 seconds for the image to be downloaded and `localfhenix` to be started. Once the container is ready, you will see the following message:

![](/img/gitpod-ss2.png)

Now that we are ready, you can use the pre-configured contract to interact with the LocalFhenix instance. You can find the contract in the `contracts` folder.

## Deploy a contract

To deploy a contract, you can use the following command:

```bash
npx hardhat deploy
```

## Interact with a contract

### Send a transaction

To interact with our counter contract, you can use the predefined hardhat tasks:

```bash
npx hardhat task:addCount --amount 10
```

### View Functions

To view the current count, you can use the following command:

```bash
npx hardhat task:getCount
```

If everything was successful, you should see output similar to the following:

```bash
gitpod /workspace/fhenix-hardhat-example (master) $ npx hardhat task:getCount
Running getCount, targeting contract at: 0xbeb4eF1fcEa618C6ca38e3828B00f8D481EC2CC2
got count: 10
got unsealed result: 10
```

## Next Steps

To learn more about the Fhenix Hardhat Plugin, please visit the [Fhenix Hardhat Plugin](/docs/fhenix-hardhat-plugin) or learn more about [Developing dApps with Fhenix](/docs/developing-dapps-with-fhenix).
61 changes: 40 additions & 21 deletions docs/devdocs/Setting Up Your Environment/Hardhat.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
* [Docker](https://www.docker.com/)
* [pnpm](https://pnpm.io/installation)

LocalFhenix is a complete Fhenix local testnet and ecosystem containerized with Docker. It simplifies the way contract developers test their contracts in a sandbox before they deploy them on a testnet or mainnet - similar to Ganache, or other local network environments.

LocalFhenix comes preconfigured with opinionated, sensible (hopefully) defaults for standard testing environments.

## Clone Hardhat Template

We provide a hardhat template available that comes "batteries included", with everything you need to hit the ground running. The template is [available here](https://github.com/fhenixprotocol/hardhat-template). You can create a new repository, or clone it locally:

```
git clone https://github.com/fhenixprotocol/hardhat-template
git clone https://github.com/fhenixprotocol/fhenix-hardhat-example
```

You'll also probably want to set an .env file with your mnemonics:
Expand All @@ -23,33 +20,55 @@ You'll also probably want to set an .env file with your mnemonics:
cp .env.example .env
```

### Start LocalFhenix
## Install Dependencies

Start the local dev environment in a separate tab using:
Once you've cloned the repository, you can install the dependencies with pnpm:

```
docker run [-d] -p 8547:8547 -p 3000:3000 -it ghcr.io/fhenixprotocol/nitro/localfhenix:latest
```sh
pnpm install
```

You can choose if you want to use the `-d` for detached run or not
### Start LocalFhenix

LocalFhenix is a complete Fhenix local testnet and ecosystem containerized with Docker. It simplifies the way contract developers test their contracts in a sandbox before they deploy them on a testnet or mainnet - similar to Ganache, or other local network environments.

To start a LocalFhenix instance, run the following command:

:::note
In this example port 8547 will be exposed as the JSON-RPC port, and port 3000 is used for fauct.
:::
```sh
pnpm localfhenix:start
```

You've now officially created a local Fhenix testnet with chain-id `412346`. 🎉
This will start a LocalFhenix instance in a docker container, managed by the `fhenix-hardhat-docker` plugin for Hardhat.
If this worked you should see a `LocalFhenix started` message in your console.

### Faucet
You've now officially created a LocalFhenix testnet. 🎉

To start developing on LocalFhenix, we'll need to send some FHE to a new address. For this, we can use the built-in faucet.
After you're done, you can stop the LocalFhenix instance with:

You can use it by accessing the following url:
```sh
pnpm localfhenix:stop
```
http://localhost:3000/faucet?address={YOUR_WALLET_ADDRESS}

### Deploy the contracts

To deploy the contracts to LocalFhenix, run the following command:

```sh
pnpm hardhat deploy
```

You can also use curl:
```bash
curl "http://localhost:3000/faucet?address={YOUR_WALLET_ADDRESS}"
```
This will compile the contracts in the `contracts` directory and deploy them to the LocalFhenix network.

(note: if you want to deploy to a different network, you can specify the network with the `--network` flag)

### Tasks

We've included a few tasks in the `tasks` directory to help you get started. You can run them with the `pnpm task` command.

```sh
pnpm task:getCount # => 0
pnpm task:addCount
pnpm task:getCount # => 1
pnpm task:addCount --amount 5
pnpm task:getCount # => 6
```
23 changes: 21 additions & 2 deletions docs/devdocs/Setting Up Your Environment/Remix.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# 🎧 Remix

To get up and running with Remix, all you need is to include is the FHE.sol solidity library to your project so the compiler will know what to do.
To get up and running with Remix, you should follow a few easy steps:

1. Add Fhenix to Metamask
2. Import `FHE.sol` from your contract
3. Optionally, use the Fhenix Remix Plugin to make your life a bit easier


## 1. Add Fhenix to Metamask

Follow the instructions in the [Fhenix Frontier](../Fhenix%20Frontier/Connecting-To.md) to add Fhenix to Metamask.

## 2. Import FHE.sol

All you need is to include is the FHE.sol solidity library to your project so the compiler will know what to do.

```solidity
import "@fhenixprotocol/contracts/FHE.sol";
```
```

## 3. Fhenix Remix Plugin

The Fhenix Remix Plugin is a browser extension that adds Fhenix support to Remix. It allows you to encrypt and decrypt data in your contracts, and to interact with the Fhenix testnet.

See the [Fhenix Remix Plugin](Fhenix-Remix-Plugin.md) for more information on how to install and use the plugin!
2 changes: 1 addition & 1 deletion docs/devdocs/Setting Up Your Environment/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Setting Up Your Environment",
"position": 4
"position": 3
}
37 changes: 10 additions & 27 deletions docs/devdocs/Setting Up Your Environment/intro.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,25 @@
---
sidebar_position: 1
title: Overview
description: Comparisons on FHE data
description: Different ways to set up your development environment for Fhenix
---

# Overview

There are a few different ways to set up an environment for development on Fhenix. All the tools you know from Solidity are mostly supported, though the addition of FHE means that a few custom tools are needed. Here we'll describe the different ways you can set up your development environment.
There are a few different ways to set up an environment for development on Fhenix. All the tools you know from Solidity are mostly supported, though the addition of FHE means that a few custom tools are helpful. Here we'll describe the different ways you can set up your development environment.

For your main deployment (either after your code is ready or if you just want to develop there) you'll probably want to deploy to the public Devnet, which you can do by [connecting to the testnet](../Fhenix%20Frontier/Connecting-To.md).&#x20;
The following environments are recommended for development on Fhenix:

We support the following development environments:

Local, Gitpod or Remix based environment.
- [Fhenix Hardhat Example](./Hardhat.md)
- [Fhenix with Remix](./Remix.md)
- [Gitpod Environment](./Gitpod.mdx)

:::note[Note]
The main developer tools are all based on Javascript & Solidity, but we have open bounties to add support for Python & Vyper!
:::

## Gitpod


## Remix

To get up and running with Remix, all you need is to include the TFHE.sol solidity files to your project so the compiler knows what to do. You can do so by importing FHE.sol from your contract directly -

```javascript
import "@fhenixprotocol/contracts/FHE.sol";
```

We also provide an example contract that can be loaded into Remix, using the "Load From Github"

<img src="../.gitbook/assets/image (1).png" alt="" data-size="original" />

Which is available from [https://github.com/FhenixProtocol/devnet-contracts/blob/main/EncryptedERC20.sol](https://github.com/FhenixProtocol/devnet-contracts/blob/main/EncryptedERC20.sol).

To connect Remix to Fhenix testnet, you can use the injected provider option after [adding to Metamask](../Fhenix%20Frontier/Connecting-To.md).

Remix can also be connected to Hardhat and LocalFhenix, though the scope of that is beyond what I feel like writing now :smile:.
If you just want to utilize one of the tools in your own environment, take a look at:

### Remix Plugin
- [Fhenix-Remix-Plugin](../Tools%20and%20Utilities/Fhenix-Remix-Plugin.md)
- [Fhenix-Encryption-UI](../Tools%20and%20Utilities/Fhenix-Encryption-UI.md)
- [Hardhat-Plugin](../Tools%20and%20Utilities/Fhenix-Hardhat-Plugin.md)
2 changes: 1 addition & 1 deletion docs/devdocs/Solidity API/FHE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# FHE
# FHE.sol

### NIL8

Expand Down
2 changes: 1 addition & 1 deletion docs/devdocs/Solidity API/Permissioned.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Permissioned.Sol Contract
# Permissioned.Sol

Abstract contract that provides EIP-712 based signature verification for access control. To learn more about why this can be important, and what EIP712 is, refer to our [Permits & Access Control](../Encryption%20and%20Privacy/Permits-Access-Control.md).

Expand Down
Loading

0 comments on commit e6a72ef

Please sign in to comment.