# ONCHAINID Interface

The ONCHAINID interface defines the set of functions and events used to manage identities and claims on the blockchain. It extends the functionality of two key interfaces: `IERC734` and `IERC735`.

**`isClaimValid`**

**Source**: `IIdentity`

This function checks if a claim is valid based on the identity contract, claim topic, signature, and data provided.

```solidity
function isClaimValid(
    IIdentity _identity,
    uint256 claimTopic,
    bytes calldata sig,
    bytes calldata data
) external view returns (bool);
```

**Description**: Validates a claim by verifying the signature and data against the specified claim topic and identity contract.

***

**`addKey`**

**Source**: `IERC734`

This function adds a key to the identity for a specified purpose and key type.

```solidity
function addKey(bytes32 _key, uint256 _purpose, uint256 _keyType) external returns (bool success);
```

**Description**: Adds a new key to the identity, where `_purpose` defines the purpose of the key (e.g., management or execution), and `_keyType` specifies the type of key (e.g., an Ethereum address or a hash of a public key).

***

**`approve`**

**Source**: `IERC734`

This function approves an execution request.

```solidity
function approve(uint256 _id, bool _approve) external returns (bool success);
```

**Description**: Approves or rejects an execution request identified by `_id`. If approved, the execution proceeds; if not, it is cancelled.

***

**`removeKey`**

**Source**: `IERC734`

This function removes a key for a specified purpose.

```solidity
function removeKey(bytes32 _key, uint256 _purpose) external returns (bool success);
```

**Description**: Removes a key associated with a particular purpose from the identity, effectively revoking its rights.

***

**`execute`**

**Source**: `IERC734`

This function executes an operation on behalf of the identity.

```solidity
function execute(address _to, uint256 _value, bytes calldata _data) external payable returns (uint256 executionId);
```

**Description**: Executes a transaction on behalf of the identity. The `_to` parameter specifies the recipient address, `_value` is the amount of Ether to send, and `_data` contains the call data. Returns an `executionId` for tracking the operation.

***

**`getKey`**

**Source**: `IERC734`

This function retrieves the full data for a specified key.

```solidity
function getKey(bytes32 _key) external view returns (uint256[] memory purposes, uint256 keyType, bytes32 key);
```

**Description**: Returns the purposes, key type, and key value for a specified key. Useful for understanding the roles and permissions associated with a key.

***

**`getKeyPurposes`**

**Source**: `IERC734`

This function returns the list of purposes associated with a key.

```solidity
function getKeyPurposes(bytes32 _key) external view returns (uint256[] memory _purposes);
```

**Description**: Retrieves all purposes assigned to a specified key, providing insight into what the key can be used for.

***

**`getKeysByPurpose`**

**Source**: `IERC734`

This function returns an array of keys associated with a specific purpose.

```solidity
function getKeysByPurpose(uint256 _purpose) external view returns (bytes32[] memory keys);
```

**Description**: Lists all keys that serve a particular purpose, aiding in the management and audit of keys within the identity.

***

**`keyHasPurpose`**

**Source**: `IERC734`

This function checks if a key has a given purpose.

```solidity
function keyHasPurpose(bytes32 _key, uint256 _purpose) external view returns (bool exists);
```

**Description**: Verifies whether a specific key is assigned a particular purpose, returning `true` if it exists and `false` otherwise.

***

**`addClaim`**

**Source**: `IERC735`

This function adds or updates a claim.

```solidity
function addClaim(
    uint256 _topic,
    uint256 _scheme,
    address issuer,
    bytes calldata _signature,
    bytes calldata _data,
    string calldata _uri
) external returns (bytes32 claimRequestId);
```

**Description**: Adds a new claim or updates an existing claim. The claim is associated with a `_topic`, uses a `_scheme` for the signature, and includes the claim's data and URI.

***

**`removeClaim`**

**Source**: `IERC735`

This function removes a claim from the identity.

```solidity
function removeClaim(bytes32 _claimId) external returns (bool success);
```

**Description**: Deletes a claim identified by `_claimId`, revoking the associated attestation.

***

**`getClaim`**

**Source**: `IERC735`

This function retrieves a claim by its ID.

```solidity
function getClaim(bytes32 _claimId)
external view returns(
    uint256 topic,
    uint256 scheme,
    address issuer,
    bytes memory signature,
    bytes memory data,
    string memory uri);
```

**Description**: Returns the full details of a claim, including its topic, scheme, issuer, signature, data, and URI.

***

**`getClaimIdsByTopic`**

**Source**: `IERC735`

This function returns an array of claim IDs for a given topic.

```solidity
function getClaimIdsByTopic(uint256 _topic) external view returns (bytes32[] memory claimIds);
```

**Description**: Lists all claim IDs associated with a specific topic, facilitating the management and audit of claims.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.erc3643.org/erc-3643/smart-contracts-library/onchain-identities/onchainid-interface.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
