> For the complete documentation index, see [llms.txt](https://docs.coti.io/coti-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coti.io/coti-documentation/build-on-coti/tools/contracts-library/tokens/private-erc20.md).

# Private ERC20

The [**Private ERC20**](https://github.com/coti-io/coti-contracts/blob/main/contracts/token/PrivateERC20/PrivateERC20.sol) contract is an abstract implementation of a privacy-enhanced ERC20 token. It introduces mechanisms for handling encrypted balances, allowing for more secure and private token transfers. This contract integrates with the MPC Core library for secure multiparty computation (MPC).

## Usage

```solidity
// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

import "@coti-io/coti-contracts/contracts/token/PrivateERC20/PrivateERC20.sol";

contract MyToken is PrivateERC20 {
    constructor() PrivateERC20("Private Token", "PTOK") {}
}
```

## Functions

```solidity
constructor(string memory name_, string memory symbol_)
```

```solidity
function name() view returns (string memory)
```

```solidity
function symbol() view returns (string memory)
```

```solidity
function decimals() view returns (uint8)
```

```solidity
function totalSupply() view returns (uint256)
```

```solidity
function accountEncryptionAddress(address account) view returns (address)
```

```solidity
function balanceOf(address account) view returns (ctUint64)
```

```solidity
function balanceOf() returns (gtUint64)
```

```solidity
function setAccountEncryptionAddress(address addr) returns (bool)
```

```solidity
function transfer(address to, itUint64 calldata value) returns (gtBool)
```

```solidity
function transfer(address to, gtUint64 value) returns (gtBool)
```

```solidity
function allowance(address owner, address spender) view returns (Allowance memory)
```

```solidity
function allowance(address account, bool isSpender) returns (gtUint64)
```

```solidity
function reencryptAllowance(address account, bool isSpender) returns (bool)
```

```solidity
function approve(address spender, itUint64 calldata value) returns (bool)
```

```solidity
function approve(address spender, gtUint64 value) returns (bool)
```

```solidity
function transferFrom(address from, address to, itUint64 calldata value) returns (gtBool)
```

```solidity
function transferFrom(address from, address to, gtUint64 value) returns (gtBool)
```

```solidity
function _transfer(address from, address to, gtUint64 value) returns (gtBool)
```

```solidity
function _update(address from, address to, gtUint64 value) returns (gtBool)
```

```solidity
function _getBalance(address account) returns (gtUint64)
```

```solidity
function _getAccountEncryptionAddress(address account) view returns (address)
```

```solidity
function _updateBalance(address account, gtUint64 balance)
```

```solidity
function _mint(address account, gtUint64 value) returns (gtBool)
```

```solidity
function _burn(address account, gtUint64 value) returns (gtBool)
```

```solidity
function _approve(address owner, address spender, gtUint64 value)
```

```solidity
function _spendAllowance(address owner, address spender, gtUint64 value)
```

```solidity
function _safeOnboard(ctUint64 value) returns (gtUint64)
```

```solidity
event Transfer(address indexed from, address indexed to, ctUint64 senderValue, ctUint64 receiverValue);
```

```solidity
event Approval(address indexed owner, address indexed spender, ctUint64 ownerValue, ctUint64 spenderValue);
```

## Errors

```solidity
error ERC20InvalidSender(address sender)
```

```solidity
error ERC20InvalidReceiver(address receiver)
```

```solidity
error ERC20InvalidApprover(address approver)
```

```solidity
error ERC20InvalidSpender(address spender)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.coti.io/coti-documentation/build-on-coti/tools/contracts-library/tokens/private-erc20.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
