# IFrictionlessAttestationManager

[Git Source](https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/blob/85f6dfa54ce0787eb1b1345bd6726f84fe766c54/contracts/interface/IFrictionlessAttestationManager.sol)

**Author:** DEFYCA Labs S.à.r.l

Copyright © 2023 DEFYCA Labs S.à.r.l Permission is hereby granted, free of charge, to any person obtaining a copy of the Frictionless protocol smart contracts (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DEFYCA LABS S.à.r.l BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The IFrictionlessAttestationManager See the flow and description of the attestation workflow in the diagram at <https://gitlab.com/dfyclabs/protocol/dfyclabs-tokens/-/raw/main/docs/img/frictionless-fund-deposit-flow-attestation.png>

## Functions

### updateAttestationToken

*Update the token address of the `FrictionlessFundDepositToken` for the `currency_` and `iban_` pair.*

```solidity
function updateAttestationToken(address tokenAddress_, string calldata iban_, string calldata currency_) external;
```

**Parameters**

| Name            | Type      | Description                                                                                                                                                                                                                                         |
| --------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tokenAddress_` | `address` | the address of deposit `FrictionlessFundDepositToken`                                                                                                                                                                                               |
| `iban_`         | `string`  | the IBAN associated with the `FrictionlessFundDepositToken`                                                                                                                                                                                         |
| `currency_`     | `string`  | the currency associated with the `FrictionlessFundDepositToken` throws `FrictionlessAttestationManagerTokenZeroAddress` if tokenAddress\_ address is a zero address emits `FrictionlessFundDepositAttestationTokenUpdated` upon successful updating |

### confirmAttestation

*Confirm the attestation by signing the signature, this is the proof of the attestation by the PERMISSIONED\_FUND\_ACCOUNTANT*

```solidity
function confirmAttestation(AttestationData calldata attestationData_, bytes calldata sig_) external;
```

**Parameters**

| Name               | Type              | Description                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `attestationData_` | `AttestationData` | attestation data to sign                                                                                                                                                                                                                                                                                                                                                                                                         |
| `sig_`             | `bytes`           | the signature to sign by the PERMISSIONED\_FUND\_ACCOUNTANT throws `FrictionlessAttestationManagerNotEnoughPermissions` if the msg.sender does not have the role PERMISSIONED\_FUND\_ACCOUNTANT throws `FrictionlessAttestationManagerInvalidAttestation` if the attestation cannot be confirmed, meaning the signed attestation cannot be verified. emits `FrictionlessFundDepositAttestationConfirmed` upon successful signing |

### minBalance

*Get the minimum balance amount configured, for which an attestation can be run. If the balance of the attestation is below the value configured, the error will be thrown. The minimum allowed is 10\_000 or 0.01*

```solidity
function minBalance() external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                  |
| -------- | --------- | ---------------------------- |
| `<none>` | `uint256` | minimum attestation balance. |

### minWindow

*Get minimum time (reportEnd - reportStart) in blocktime for which an attestation can be run. Typically this is 1 hour, and dependent on the availability of transaction data in the underlying fund account as specified by the IBAN. The minimum allowed is 300 seconds.*

```solidity
function minWindow() external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `<none>` | `uint256` | minimum attestation window. |

### maxWindow

*Get maximum time (reportEnd - reportStart) in blocktime for which an attestation can be run. Typically this is 30 days, aligned with the reporting as per regulation for the underlying fund and issuer of the deposit token. The maximum allowed is 365 days.*

```solidity
function maxWindow() external view returns (uint256);
```

**Returns**

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `<none>` | `uint256` | maximum attestation window. |

### getAccountAttestationDataKeys

*Retrieves the keys of attestation data associated with a specific account identified by IBAN and currency.*

```solidity
function getAccountAttestationDataKeys(string calldata iban_, string calldata currency_)
    external
    view
    returns (bytes32[] memory);
```

**Parameters**

| Name        | Type     | Description                                                     |
| ----------- | -------- | --------------------------------------------------------------- |
| `iban_`     | `string` | the IBAN associated with the `FrictionlessFundDepositToken`     |
| `currency_` | `string` | the currency associated with the `FrictionlessFundDepositToken` |

**Returns**

| Name     | Type        | Description                                                             |
| -------- | ----------- | ----------------------------------------------------------------------- |
| `<none>` | `bytes32[]` | the array of bytes32 attestation data keys associated with the account. |

### getAccountLastAttestationData

*Retrieves the last attestation data associated with a specific account identified by IBAN and currency.*

```solidity
function getAccountLastAttestationData(string calldata iban_, string calldata currency_)
    external
    view
    returns (AttestationData memory);
```

**Parameters**

| Name        | Type     | Description                                                     |
| ----------- | -------- | --------------------------------------------------------------- |
| `iban_`     | `string` | the IBAN associated with the `FrictionlessFundDepositToken`     |
| `currency_` | `string` | the currency associated with the `FrictionlessFundDepositToken` |

**Returns**

| Name     | Type              | Description                                                                                      |
| -------- | ----------------- | ------------------------------------------------------------------------------------------------ |
| `<none>` | `AttestationData` | the `AttestationData` struct representing the last attestation data associated with the account. |

### getAccountLastAttestationDataKey

*Retrieves the key of the last attestation data associated with a specific account identified by IBAN and currency.*

```solidity
function getAccountLastAttestationDataKey(string calldata iban_, string calldata currency_)
    external
    view
    returns (bytes32);
```

**Parameters**

| Name        | Type     | Description                                                     |
| ----------- | -------- | --------------------------------------------------------------- |
| `iban_`     | `string` | the IBAN associated with the `FrictionlessFundDepositToken`     |
| `currency_` | `string` | the currency associated with the `FrictionlessFundDepositToken` |

**Returns**

| Name     | Type      | Description                                                |
| -------- | --------- | ---------------------------------------------------------- |
| `<none>` | `bytes32` | the last attestation data key associated with the account. |

### getAttestationData

*Retrieves attestation data by the attestation data key.*

```solidity
function getAttestationData(bytes32 attestationDataKey_) external view returns (AttestationData memory);
```

**Parameters**

| Name                  | Type      | Description                              |
| --------------------- | --------- | ---------------------------------------- |
| `attestationDataKey_` | `bytes32` | the key identifying the attestation data |

**Returns**

| Name     | Type              | Description                                                                                 |
| -------- | ----------------- | ------------------------------------------------------------------------------------------- |
| `<none>` | `AttestationData` | the AttestationData struct representing the attestation data associated with the given key. |

### getTokenAddress

*Get the valid `FrictionlessFundDepositToken` for the `currency_` and `iban_` pair.*

```solidity
function getTokenAddress(string memory iban_, string memory currency_) external view returns (address);
```

**Parameters**

| Name        | Type     | Description                                                   |
| ----------- | -------- | ------------------------------------------------------------- |
| `iban_`     | `string` | the IBAN associated with the FrictionlessFundDepositToken     |
| `currency_` | `string` | the currency associated with the FrictionlessFundDepositToken |

**Returns**

| Name     | Type      | Description                                                                                  |
| -------- | --------- | -------------------------------------------------------------------------------------------- |
| `<none>` | `address` | the address of the valid `FrictionlessFundDepositToken` for the `currency_` and `iban_` pair |

### getAttestationDataHash

*Mint a new attestation, it returns hash of attestation data to sign by the PERMISSIONED\_FUND\_ACCOUNTANT*

```solidity
function getAttestationDataHash(AttestationData calldata attestationData_) external view returns (bytes32);
```

**Parameters**

| Name               | Type              | Description                                                                                     |
| ------------------ | ----------------- | ----------------------------------------------------------------------------------------------- |
| `attestationData_` | `AttestationData` | the complete set of attestation data to for the PERMISSIONED\_FUND\_ACCOUNTANT to certify/sign. |

**Returns**

| Name     | Type      | Description                                                                   |
| -------- | --------- | ----------------------------------------------------------------------------- |
| `<none>` | `bytes32` | a hash of the attestationData which will be signed to confirm the attestation |

### getAccountAttestationKey

*Retrieves the attestation data key associated with a specific account identified by currency and IBAN.*

```solidity
function getAccountAttestationKey(string calldata currency_, string calldata iban_) external pure returns (bytes32);
```

**Parameters**

| Name        | Type     | Description                                                     |
| ----------- | -------- | --------------------------------------------------------------- |
| `currency_` | `string` | the currency associated with the `FrictionlessFundDepositToken` |
| `iban_`     | `string` | the IBAN associated with the `FrictionlessFundDepositToken`     |

**Returns**

| Name     | Type      | Description                  |
| -------- | --------- | ---------------------------- |
| `<none>` | `bytes32` | the accound attestation key. |

## Events

### FrictionlessFundDepositAttestationTokenUpdated

*Emitted when the `FrictionlessFundDepositToken` is updated in the `IFrictionlessAttestationManager`.*

```solidity
event FrictionlessFundDepositAttestationTokenUpdated(
    bytes32 accountAttestationKey, address newTokenAddress, address oldTokenAddress
);
```

### FrictionlessFundDepositAttestationConfirmed

*Event emitted upon the confirmation of a `FrictionlessFundDepositToken` in the `IFrictionlessAttestationManager`*

```solidity
event FrictionlessFundDepositAttestationConfirmed(AttestationData attestationData);
```

## Errors

### FrictionlessAttestationManagerCallerNotAProtocolTreasury

*thrown if msg.sender address is not a PROTOCOL\_TREASURY, during `updateAttestationToken`*

```solidity
error FrictionlessAttestationManagerCallerNotAProtocolTreasury(address caller);
```

### FrictionlessAttestationManagerTokenZeroAddress

*thrown if tokenAddress\_ address is a zero address, during `updateAttestationToken`*

```solidity
error FrictionlessAttestationManagerTokenZeroAddress();
```

### FrictionlessAttestationManagerPermissionsZeroAddress

*thrown if permissionManagerAddr\_ address is a zero address, during `init`*

```solidity
error FrictionlessAttestationManagerPermissionsZeroAddress();
```

### FrictionlessAttestationManagerInvalidToken

*thrown if the `FrictionlessFundDepositToken` has not been registered for the IBAN, currency pair.*

```solidity
error FrictionlessAttestationManagerInvalidToken(string iban, string currency);
```

### FrictionlessAttestationManagerInvalidReport

*thrown if the passed `AttestationData` report is invalid.*

```solidity
error FrictionlessAttestationManagerInvalidReport(AttestationData attestationData);
```

### FrictionlessAttestationManagerBalanceTooLow

*thrown if the attestation balance is too small, below the configurable amount.*

```solidity
error FrictionlessAttestationManagerBalanceTooLow(uint256 balance);
```

### FrictionlessAttestationManagerDuplicateLastTxHash

*thrown if the last transaction hash for the attestation has already been used, this avoids duplicate attestations.*

```solidity
error FrictionlessAttestationManagerDuplicateLastTxHash(string lastTxHash);
```

### FrictionlessAttestationManagerInvalidAttestationSigner

*thrown if the attestation cannot be confirmed, meaning the signed attestation cannot be verified.*

```solidity
error FrictionlessAttestationManagerInvalidAttestationSigner(address signer, bytes32 attestationHash, bytes sig);
```

## Structs

### AttestationData

*struct to hold attestation data, which is designed to provide the most recent attestation of balance and verified last transaction in an attestation window.*

```solidity
struct AttestationData {
    address tokenAddr;
    string iban;
    string currency;
    uint256 reportStart;
    uint256 reportEnd;
    uint256 balance;
    string lastTxHash;
}
```

### AccountAttestationData

*struct to hold account attestation data*

```solidity
struct AccountAttestationData {
    address attestationTokenAddr;
    bytes32 lastAttestationDataKey;
    EnumerableSet.Bytes32Set allAttestationDataKeys;
}
```


---

# 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.frictionless.markets/developer/smart-contracts/smart-contract-docs/manager-contracts/ifrictionlessattestationmanager.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.
