Clément 'birdy' Danjou 8fdc9f331c fix() set contract owner
2023-07-06 13:07:59 +02:00
2023-07-06 13:07:59 +02:00
2023-06-14 16:12:59 +02:00
2023-06-23 14:01:53 +02:00
2023-06-30 17:36:21 +02:00
2023-06-30 17:36:21 +02:00

fhEVM

A Solidity library for interacting with the Zama Blockchain

Install

npm install fhevm

or

yarn install fhevm

Usage

// SPDX-License-Identifier: BSD-3-Clause-Clear

pragma solidity >=0.8.13 <0.9.0;

import "fhevm/lib/TFHE.sol";

contract Counter {
  euint32 counter;

  constructor() {}

  function add(bytes calldata encryptedValue) public {
    euint32 value = TFHE.asEuint32(encryptedValue);
    counter = TFHE.add(world, value);
  }

  function getCounter(bytes32 publicKey) returns (bytes memory) {
    return TFHE.reencrypt(totalSupply, publicKey);
  }
}

See our documentation on https://docs.zama.ai/homepage/ for more examples.

Development Guide

Install dependencies (Solidity libraries and dev tools)

npm install

Note: Solidity files are formatted with prettier.

Generate TFHE lib

npm run codegen

WARNING: Use this command to generate Solidity code and prettier result automatically!

Demo Test

This repository includes a python script (see demo_test.py) that automates a sequence of steps simulating deployment and interaction with an encrypted ERC20 contract.

Because inputs must be encrypted using the blockchain global public key, a tool called zbc-fhe-tool is available.

We also need the blockchain public key, please copy it into keys/network-public-fhe-keys/ named pks.

The python script accepts two arguments:

  1. The private key of the main account which owns funds
  2. [optionnal --node_address] The node @ (default is http://host.docker.internal:8545)

To install all the required python modules, a docker is available containing zbc-fhe-tool binary.

Run the demo test:

export PRIVATE_KEY=CCABB56366...
docker compose -f ci/docker-compose.yml run app python demo_test.py $PRIVATE_KEY

Install zbc-fhe-tools
make install-zbc-fhe-tool

#The binary will be available at work_dir/zbc-fhe-tool/target/release/zbc-fhe-tool


Description
No description provided
Readme BSD-3-Clause 22 MiB
Languages
TypeScript 99.4%
Python 0.5%