Skip to content
Merged
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
68 changes: 6 additions & 62 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All repositories specified below contain smart contracts that implement confiden
The contracts provide examples for various use cases, such as Non-Fungible Tokens (NFTs), ERC20 tokens, Auction, and Identity management.

These contracts demonstrate how to leverage the confidentiality features of the COTI V2 protocol to enhance privacy and security in decentralized applications.
The contracts are of Solidity and can be compiled and deployed using popular development tools like Hardhat and Foundry (Work in progress).
The contracts are written in Solidity and can be compiled and deployed using popular development tools like Hardhat and Foundry.

#### Important Links:

Expand Down Expand Up @@ -38,38 +38,19 @@ The following contracts are available in each of the packages:
(*) no deployment needed (system contract)

> [!NOTE]
> Due to the nature of ongoing development, future version might break existing functionality
> Due to the nature of ongoing development, future versions might break existing functionality

### Faucet

🤖 To request devnet/testnet funds use our [faucet](https://faucet.coti.io)

# COTI v2 Python SDK

The COTI Python SDK can be installed as a package named: ```coti_sdk```, The package is called ``` coti ``` and modules are:
1. ```crypto_utils ``` : handling all cryptography specific related operations
2. ```utils ``` : handling web3 related operations

To view Python script examples (see repository link at the top): the examples project contain scripts 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.
These contracts demonstrate how to leverage the confidentiality features of the COTI V2 protocol to enhance privacy and
security in decentralized applications.

The contracts are written in Solidity and can be compiled and deployed using popular development frameworks such as
Hardhat and Foundry, For some of them there is an option for deployment via python (review the table).

The following example contracts are available in the Python SDK for deployment and execution:

| Contract | Contract Description |
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| 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 |
| ERC20Example | Confidential ERC20 - deploy and transfer encrypted amount of funds |
| DataOnChain | Basic encryption and decryption - Good place to start exploring network capabilities |
| Precompile | Thorough examples of the precompile functionality |
The COTI Python SDK can be installed as pypi package named `coti_sdk`, its modules are:
1. `crypto_utils`: used for cryptographic operations
2. `utils` : used for web3 related operations

> [!NOTE]
> Due to the nature of ongoing development, future versions might break existing functionality
The [Python script examples](https://github.com/coti-io/coti-sdk-python-examples) project contain scripts covering various use cases, such as Non-Fungible Tokens (NFTs), ERC20 tokens, Auctions, and Identity management. It contains smart contracts that implement confidentiality features using the COTI V2 protocol. These contracts demonstrate how to leverage the confidentiality features of the COTI V2 protocol to implement privacy and enhance security in decentralized applications.

## Getting initial funds from the COTI Faucet

Expand All @@ -88,38 +69,6 @@ For Example:
devnet 0x71C7656EC7ab88b098defB751B7401B5f6d8976F
```

## Python SDK Usage

The sample contracts described above reside in the [coti-sdk-python/examples](/examples/) directory. The solidity
contracts are in the [confidentiality-contracts](/confidentiality-contracts/) directory which is imported as a git
submodule.

When a script executed (for example `data_on_chain.py`) it will deploy the contract and create a json file with the
details of the deployed
contract under the `/compiled_contracts` directory.

Inspect the `.env` file for more details.

The python examples utilizes primitive deployment management that mostly checks if there is a json file under
the `/compiled_contracts` directory
and doesn't deploy a new one in case one already exists, otherwise it deploys.

### Getting Started

1. Generate EOA: Run the `native_transfer.py` script, it will transfer tiny amount to some random address -
demonstrating standard native transfer.
It will create a new EOA (you will see your public address in the script output), and the account private key will be
recorded in your `.env` file.
It will fail on first run since the account doesn't have any funds. Refer to the Faucet section above

2. Generate Encryption Key: Run the `onboard_account.py` script, it will ask the network for the AES encryption key
specific for this account and
it will log it in the `.env` file (mandatory for every action that performs COTI v2 onchain computation).

3. Execute: Now you can run any other example, such as `precompiles_examples.py` (see above for complete list).

In order to follow the transactions sent to the node, use the `web_socket.py` to be notified and see on-chain details.

## Libraries

There are two libraries located in the [libs](/libs/) folder that will allow you to interact with the COTI network.
Expand Down Expand Up @@ -747,9 +696,4 @@ decrypted_balance = decrypt_value(contract_value, user_key)

- `decrypted_balance`: The decrypted value.

## Pending enhancements

* Extending examples such as confidential ERC20 minting, confidential NFT (deployment and actions) and more.

#### To report issues, please create a [github issue](https://github.com/coti-io/coti-sdk-python/issues)