Hazel
February 28, 2023, 2:03pm
1
Have we settled on an ERC-165 like standard yet? I know we’ve had discussions and all the early contracts included some version of this. Since we’re working towards ICRC standards now I think we should try to get something done quick.
icrc13_supports_interface
Given a text
interface name like ICRC1
, DLIP1v1
, EXT
returns a bool
icrc13_supported_interfaces
Given a text
interface returns a vec text
of all supported interfaces.
service : {
icrc13_supports_interface : (text) -> (bool);
icrc13_supported_interfaces : () -> (vec text);
}
opened 07:40PM - 28 Feb 23 UTC
```
icrc: 13
title: ICRC-13 Canister Interface Detection
authors: ?
discussi… ons-to: https://github.com/dfinity/ICRC/issues/13
status: Deliberating
category: ICRC
requires: None
supports: ICRC-12 (optional)
created: 2023-02-28
updated: 2023-02-28
```
# Summary
A set of methods for publishing and detecting which interfaces a canister implements.
# References
[ERC-165](https://eips.ethereum.org/EIPS/eip-165)
# Introduction
The following is a simple [ERC-165](https://eips.ethereum.org/EIPS/eip-165) like standard for the internet computer. This standard allows canister developers to explicitly state which standards their canisters supports. This allows integrators to programmatically negotiate how best to communicate between canisters.
# Notes
* Canisters on the IC are potentially mutable. We should discuss best practices for how to leverage this standard as an integrator.
* A follow up standard might be created allowing canisters to declare a dependency on a canister and interface.
* Canisters implementing this standard should not be taken at face value. It is up to the developer interfacing with a canister implementing this standard to be aware of potential attack vectors.
* For example a canister could claim to be the ICRC-1 ICP token canister. Don't blindly index off token name.
# Standard
## `icrc13_supports_interface`
Given a text interface name like ICRC1, DLIP1v1, EXT returns a bool
## `icrc13_supported_interfaces`
Given a text interface returns a `vec text` of all supported interfaces.
## Candid
```candid
service : {
icrc13_supports_interface : (text) -> (bool);
icrc13_supported_interfaces : () -> (vec text);
}
```
## Events
Canisters which implement this standard can choose to optionally implement the [ICRC-12](https://github.com/dfinity/ICRC/issues/12) events. Support is optional. However, If developers choose to implement events for ICRC-13 developers MUST implement all of the following ICRC-13 events.
```candid
type InterfaceAction = variant {
InterfaceAdded : text; // event_schema = "icrc13.v1.interface.added"
InterfaceRemoved : text; // event_schema = "icrc13.v1.interface.removed"
};
type InterfaceUpdated = record {
updated_at : u64; // When the mutation occurred.
action : opt; // Optional to allow for modification of types
}
```
10 Likes