Skip to content

Latest commit

 

History

History
102 lines (68 loc) · 3.15 KB

README.md

File metadata and controls

102 lines (68 loc) · 3.15 KB

fhEVM Contracts

Description

fhEVM contracts is a Solidity library for secure smart-contract development using fhEVM and TFHE.

Getting Started

Installation

You can import this repo using your package manager.

# Using npm
npm install fhevm-contracts

# Using Yarn
yarn add fhevm-contracts

# Using pnpm
pnpm add fhevm-contracts

Simple contract

To write Solidity contracts that use TFHE and/or Gateway, it is required to set different contract addresses.

Fortunately, the fhevm repo, one of this repo's dependencies, exports config files that can be inherited to simplify the process. The config should be the first to be imported in the order of the inherited contracts.

Using the mock network (for testing)

// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import { MockZamaFHEVMConfig } from "fhevm/config/ZamaFHEVMConfig.sol";
import { EncryptedERC20 } from "fhevm-contracts/contracts/token/ERC20/EncryptedERC20.sol";

contract MyERC20 is MockZamaFHEVMConfig, EncryptedERC20 {
  constructor() EncryptedERC20("MyToken", "MYTOKEN") {
    _unsafeMint(1000000, msg.sender);
  }
}

Using Sepolia

// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import { SepoliaZamaFHEVMConfig } from "fhevm/config/ZamaFHEVMConfig.sol";
import { EncryptedERC20 } from "fhevm-contracts/contracts/token/ERC20/EncryptedERC20.sol";

contract MyERC20 is SepoliaZamaFHEVMConfig, EncryptedERC20 {
  constructor() EncryptedERC20("MyToken", "MYTOKEN") {
    _unsafeMint(1000000, msg.sender);
  }
}

Available contracts

These Solidity templates include governance-related and token-related contracts.

Token

Governance

Utils

Contributing

There are two ways to contribute to the Zama fhEVM contracts:

Becoming an approved contributor involves signing our Contributor License Agreement (CLA). Only approved contributors can send pull requests, so please make sure to get in touch before you do.

License

[!CAUTION] Smart contracts are a nascent technology that carry a high level of technical risk and uncertainty. You are solely responsible for any use of the fhEVM Contracts and you assume all risks associated with any such use.

This software is distributed under the BSD-3-Clause-Clear license. If you have any question about the license, please contact us at [email protected].