CIS-0: Standard Detection¶
Jul 14, 2022
Aug 3, 2022
Smart contract version 1 or newer
(Protocol version 4 or newer)
A standardized interface for how a smart contract indicates supported smart contract standards. Additionally, this specification includes a list of identifiers for each standard used on the Concordium blockchain.
The interface provides an entrypoint for querying the smart contract about whether it supports a given standard. The smart contract responds with either: not supported, supported or supported by some contract address.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
Each standard MUST have a unique identifier. An identifier is a variable-length ASCII string up to 255 characters.
The identifier is serialized as: first 1 byte for the length followed this many bytes for the ASCII encoding of the identifier:
StandardIdentifier ::= (n: Byte) (id: Byteⁿ)
A smart contract implementing CIS-0 MUST export the following function: supports.
Query supported standards using a list of standard identifers. The response contains a corresponding result for each standard identifier, where the result is either “Standard is not supported”, “Standard is supported by this contract” or “Standard is supported by using some contract address”.
The result of “Standard is supported by using some contract address” can be used to add support for smart contract standards in another smart contract. This could be to split up logic or to later add support for a new standard.
The parameter consists of a list of standard identifers.
It is serialized as: 2 bytes for the number (little endian) of standard identifers and then this number of Standard identifer identifers:
SupportsParameter ::= (n : Byte²) (ids: StandardIdentifierⁿ)
The function output is a list of support results, where the order of the support results matches the order of standard identifers in the parameter.
It is serialized as: 2 bytes for the number (little endian) of results (
n) and then this number of support results (
A support result is serialized as either: a byte with value
0 for “Standard is not supported”, a byte with the value
1 for “Standard is support by this contract” or a byte with value
2 for “Standard is supported by using another contract address” followed by a single byte encoding the number of contract addresses, then this number of contract addresses (
A contract address is serialized as: first 8 bytes for the index (
index) followed by 8 bytes for the subindex (
subindex) both little endian:
ContractAddress ::= (index: Byte⁸) (subindex: Byte⁸) SupportResult ::= (0 : Byte) // Standard is not supported | (1 : Byte) // Standard is supported by this contract | (2 : Byte) (n: Byte) (address: ContractAddressⁿ) // Standard is supported by using one of these contract addresses. SupportsResponse ::= (n : Byte²) (results: SupportResultⁿ)
The sequence of results in the response MUST correspond to the sequence of queries in the parameter.
The contract function MAY reject if any of the queries fail to produce a result.
The result for querying the support of
CIS-0for a smart contract implementing this specification MUST NOT be “Standard is not supported”.