{"id":20812682,"url":"https://github.com/coti-io/confidentiality-contracts","last_synced_at":"2025-05-11T20:30:27.484Z","repository":{"id":236160091,"uuid":"778759627","full_name":"coti-io/confidentiality-contracts","owner":"coti-io","description":"Confidential Contracts for COTI - Privacy Preserving L2","archived":true,"fork":false,"pushed_at":"2024-12-12T13:58:19.000Z","size":484,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-31T18:48:37.914Z","etag":null,"topics":["blockchain","ethereum","garbled-circuits","l2","on-chain-compute","privacy","web3"],"latest_commit_sha":null,"homepage":"https://coti.io","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coti-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-28T10:50:45.000Z","updated_at":"2025-02-20T17:12:06.000Z","dependencies_parsed_at":"2024-05-12T21:23:13.024Z","dependency_job_id":"7db33a49-06a2-42e9-b796-12b6f429eb62","html_url":"https://github.com/coti-io/confidentiality-contracts","commit_stats":null,"previous_names":["coti-io/confidentiality-contracts"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coti-io%2Fconfidentiality-contracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coti-io%2Fconfidentiality-contracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coti-io%2Fconfidentiality-contracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coti-io%2Fconfidentiality-contracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coti-io","download_url":"https://codeload.github.com/coti-io/confidentiality-contracts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253631833,"owners_count":21939360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","ethereum","garbled-circuits","l2","on-chain-compute","privacy","web3"],"created_at":"2024-11-17T20:56:54.096Z","updated_at":"2025-05-11T20:30:27.443Z","avatar_url":"https://github.com/coti-io.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!WARNING]\n\u003e This repository has been deprecated. Please use our new [contract library](https://github.com/coti-io/coti-contracts) and [contract examples](https://github.com/coti-io/coti-contracts-examples) repositories.\n\n# COTI V2 Confidentiality Preserving L2 | SDKs and Examples\n\nAll repositories specified below contain smart contracts that implement confidentiality features using the COTI V2 protocol.\nThe contracts provide examples for various use cases, such as Non-Fungible Tokens (NFTs), ERC20 tokens, Auction, and Identity management.\n\nThese contracts demonstrate how to leverage the confidentiality features of the COTI V2 protocol to enhance privacy and security in decentralized applications.\nThe contracts are of Solidity and can be compiled and deployed using popular development tools like Hardhat and Foundry (Work in progress).\n\n#### Important Links:\n\n[Docs](https://docs.coti.io) | [Devnet Explorer](https://explorer-devnet.coti.io) | [Discord](https://discord.gg/cuCykh8P4m) | [Faucet](https://faucet.coti.io)\n\nInteract with the contract using any of the following:\n\n1. [Python SDK](https://github.com/coti-io/coti-sdk-python) | [Python SDK Examples](https://github.com/coti-io/coti-sdk-python-examples)\n2. [Typescript SDK](https://github.com/coti-io/coti-sdk-typescript) | [Typescript SDK Examples](https://github.com/coti-io/coti-sdk-typescript-examples)\n3. [Hardhat Dev Environment](https://github.com/coti-io/confidentiality-contracts)\n\nThe following contracts are available in each of the packages:\n\n| Contract                       |            | python sdk  | hardhat sdk | typescript sdk | Contract Description                                                                                                                          |\n|--------------------------------|------------|-------------|-------------|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| `AccountOnboard`               | deployment | ✅ *        | ✅           | ❌              | Onboard a EOA account - During onboard network creates AES unique for that EOA which is used for decrypting values sent back from the network |\n| `AccountOnboard`               | execution  | ✅          | ✅           | ✅              | \"                                                                                                                                             |\n| `ERC20Example`                 | deployment | ✅          | ✅           | ❌              | Confidential ERC20 - deploy and transfer encrypted amount of funds                                                                            |\n| `ERC20Example`                 | execution  | ✅          | ✅           | ✅              | \"                                                                                                                                             |\n| `NFTExample`                   | deployment | ❌          | ✅           | ❌              | Confidential NFT example - saving encrypted data                                                                                              |\n| `NFTExample`                   | execution  | ❌          | ✅           | ❌              | \"                                                                                                                                             |\n| `ConfidentialAuction`          | deployment | ❌          | ✅           | ❌              | Confidential auction - encrypted bid amount                                                                                                   |\n| `ConfidentialAuction`          | execution  | ❌          | ✅           | ❌              | \"                                                                                                                                             |\n| `ConfidentialIdentityRegistry` | deployment | ❌          | ✅           | ❌              | Confidential Identity Registry - Encrypted identity data                                                                                      |\n| `ConfidentialIdentityRegistry` | execution  | ❌          | ✅           | ❌              | \"                                                                                                                                             |\n| `DataOnChain`                  | deployment | ✅          | ❌           | ❌              | Basic encryption and decryption - Good place to start explorining network capabilties                                                         |\n| `DataOnChain`                  | execution  | ✅          | ❌           | ✅              | \"                                                                                                                                             |\n| `Precompile`                   | deployment | ✅          | ✅           | ❌              | Thorough examples of the precompile functionality                                                                                             |\n| `Precompile`                   | execution  | ✅          | ✅           | ❌              | \"                                                                                                                                             |-              |              \n\n(*) no deployment needed (system contract)\n\n\u003e [!NOTE]  \n\u003e Due to the nature of ongoing development, future version might break existing functionality\n\n### Faucet\n\n🤖 To request devnet/testnet funds use our [faucet](https://faucet.coti.io)\n\n# Hardhat ([confidential-contracts](https://github.com/coti-io/confidentiality-contracts))\n\n\u003e [!NOTE]\n\u003e Please refer to the latest [tags](https://github.com/coti-io/confidentiality-contracts/tags) to find the most stable version to use.\n\nThe `confidentiality-contracts` project is composed of three main components:\n\n1. **Reference libraries** (located in `contracts/lib`): containts the `MpcCore` and `MpcInterface` libraries referenced by all other SDKs. These libraries contain instructions for methods which the gcEVM handles as bytecode. For a full description of the libraries visit the [libraries readme](contracts/lib/lib_readme.md).\n\n2. **gcEVM Precompiles** (located in `contracts/examples/precompiles`): These are a set of examples that make use of the reference libraries mentioned above. For a full description of these precompiles visit the [precompiles readme](contracts/examples/precompiles/precompiles_readme.md).\n\n3. **Example contracts** (located in `contracts/examples`): the examples folder contain Solidity contracts that perform various use cases, such as Non-Fungible Tokens (NFTs), ERC20 tokens, Auction, and Identity management. It contains smart contracts that implement confidentiality features using the COTI V2 protocol.\n\nThe following example contracts are available for Hardhat Runtime Environment for deployment and execution:\n\n| Contract                     | Contract Description                                                                                                                          |\n|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| AccountOnboard               | Onboard a EOA account - During onboard network creates AES unique for that EOA which is used for decrypting values sent back from the network |\n| ERC20Example                 | Confidential ERC20 - deploy and transfer encrypted amount of funds                                                                            |\n| NFTExample                   | Confidential NFT example - saving encrypted data                                                                                              |\n| ConfidentialAuction          | Confidential auction - encrypted bid amount                                                                                                   |\n| ConfidentialIdentityRegistry | Confidential Identity Registry - Encrypted identity data                                                                                      |\n| Precompile                   | Thorough examples of the precompile functionality                                                                                             |\n\n## Usage\n\n### ERC20Example\n\nThe following process will help you run the [**ERC20Example.sol**](/contracts/examples/ERC20Example.sol) example from the [**COTI confidentiality-contracts**](https://github.com/coti-io/confidentiality-contracts) project. The contract defines a custom ERC20 token called `ERC20Example` that extends the functionality of the ConfidentialERC20 token. Additionally it will:\n\n* Create a EOA (Externally Owned Account)\n* Validate minimum balance\n\nThe contract is compiled and deployed with Hardhat using the [`confidential-erc20.test.ts`](/test-hardhat/confidential-erc20.test.ts) test suite contained in the [`test-hardhat`](/test-hardhat) directory of the project.\n\n\u003e [!NOTE]  \n\u003e Ensure your environment meets all the pre-requisites. Visit the [pre-requisites section of the readme](/README.md).\n\n1.  Clone the confidentiality-contracts  repo\n\n    ```bash\n    git clone https://github.com/coti-io/confidentiality-contracts.git\n    ```\n\n\n2.  Change directory to the newly create one\n\n    ```bash\n    cd confidentiality-contracts\n    ```\n\n\n3.  Install dependencies\n\n    ```bash\n    yarn\n    ```\n\n\n4.  Build and compile contracts\n\n    ```bash\n    yarn build\n    ```\n\n\n5.  Run the `test-erc20` test suite\n\n    ```bash\n    yarn test-erc20\n    ```\n\n    Running this test will automatically create an account and a key/value pair with name: `SIGNING_KEYS` (visible in the .env file). The script will output something like this:\n\n\n    ```bash\n    yarn run v1.22.22\n\n      Confidential ERC20\n        1) \"before all\" hook in \"Confidential ERC20\"\n\n      0 passing (39ms)\n      1 failing\n\n      1) Confidential ERC20\n           \"before all\" hook in \"Confidential ERC20\":\n         Error: Created new random account 0x17EDB982c3569D29EbaF407F72aDD05722d5f179.\n         Please use faucet to fund it.\n    ```\n\n    \\\n    It is normal to receive the exception `Error: Created new random account [...] Please use faucet to fund it.` on the first run. This will be resolved once the account is funded.  \n\n6. Head to the faucet at [**https://faucet.coti.io**](https://faucet.coti.io) to get devnet funds. \\\n   Send the following message to the BOT using your newly created account, visible in the last part of the response.\\\n   \\\n   `devnet \u003caccount address\u003e`\\\n   \\\n   The bot will reply with the message:\\\n   \\\n   `\u003cusername\u003e faucet transferred 10 COTIv2 (devnet)` \\\n   \u0026#x20;\n7.  Run the `test-erc20` test suite once more.\n\n    ```bash\n    yarn test-erc20\n    ```\n\n    \\\n    The script output will look like this:  \n\n\n    ```bash\n    Confidential ERC20\n    ************* Onboarding user  0x17EDB982c3569D29EbaF407F72aDD05722d5f179  *************\n    ************* Onboarding user  0xe1E7315F6970F353661fc84FFd9238133cED3677  *************\n    ************* Onboarded! created user key and saved into .env file *************\n    ************* Onboarded! created user key and saved into .env file *************\n        Deployment\n          ✔ Deployed address should not be undefined\n          ✔ Owner initial balance (123ms)\n          ✔ Function 'name' should be correct (130ms)\n          ✔ Function 'symbol' should be correct (123ms)\n          ✔ Function 'decimals' should be correct (119ms)\n          ✔ Function 'totalSupply' should be correct (117ms)\n        Transfer 5\n          ✔ Transfer - clear (9469ms)\n          ✔ Transfer - Confidential (5260ms)\n          ✔ TransferFrom - clear without giving allowance should fail (9905ms)\n          ✔ TransferFrom - clear (9770ms)\n          ✔ TransferFrom - Confidential (10265ms)\n          ✔ Approve/Allowance - Confidential (10255ms)\n\n      12 passing (1m)\n\n    ✨  Done in 69.69s.\n    ```\n\n\nRunning the test suite does the following:\n\n* **Deploys the `ERC20Example` contract**: Sets up the token with specific details (name, symbol, initial supply).\n* **Tests the deployment**: Verifies the contract address, initial balance, and token details (name, symbol, decimals, total supply).\n* **Tests transfers**: Both clear and confidential transfers, including `transferFrom` functionality with and without prior allowance.\n* **Tests approvals and allowances**: Ensures that the contract correctly handles approvals and allowances, both clear and confidential.\n\n8. You may also run specific tests\n\n   ```\n   yarn test-nft\n   ```\n\n   or\n\n   ```\n   yarn test-erc20\n   ```\n\n   or\n\n   ```\n   yarn test-auction\n   ```\n\n   or\n\n   ```\n   yarn test-identity\n   ```\n   \n   or\n\n   ```\n   yarn test-precompiles\n   ```\n### Add contracts to your Hardhat project\n\n```shell\nyarn add git@github.com:coti-io/confidentiality-contracts.git\n```\n\nThis command installs the confidentiality contracts from the specified Git repository using the Yarn package manager for Hardhat projects. After installation, you can import and use the contracts in your Solidity code.\n\n#### To report issues, please create a [github issue](https://github.com/coti-io/confidentiality-contracts/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoti-io%2Fconfidentiality-contracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoti-io%2Fconfidentiality-contracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoti-io%2Fconfidentiality-contracts/lists"}