Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSP61 #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions PSPs/drafts/psp-61.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ This proposal aims to define the interface detection standard for WebAssembly sm

## Motivation

Motivation of this proposal is to provide a standard way for smart contracts to detect the interface of the smart contract they are interacting with.
This is useful for smart contracts which interact with other smart contracts, as it allows them to detect the interface of the smart contract they are interacting with and adjust their behavior accordingly,
Motivation of this proposal is to provide a standard way for smart contracts to detect the interface of the smart contract they are interacting with.
This is useful for smart contracts which interact with other smart contracts, as it allows them to detect the interface of the smart contract they are interacting with and adjust their behavior accordingly,
without having any ABI of that contracts.

## Specification

### 1. Interface ID (TRAIT_ID)

Interface ID is a 4-byte identifier of the interface, stored in `u32` big-endian format. It is calculated as the first 4 bytes of the blake2b hash of the string,
Interface ID is a 4-byte identifier of the interface, stored in `u32` big-endian format. It is calculated as the first 4 bytes of the blake2b hash of the string,
that is concatenation of all messages, sorted in lexicographical order. Such as in the example below:
varex83 marked this conversation as resolved.
Show resolved Hide resolved

```rust
Expand All @@ -31,7 +31,7 @@ message_selectors.sort_unstable();
let trait_id = ::ink_ir::Selector::compute(&message_selectors.join("").into_bytes()).into_be_u32();
```

Where `message_selectors` is a vector of all message selectors of the interface in the format `<trait-name>::<message-name>`,
Where `message_selectors` is a vector of all message selectors of the interface in the format `<trait-name>::<message-name>`,
and `::ink_ir::Selector::compute` that computes the BLAKE-2 256-bit based selector from the given input bytes.

```rust
Expand Down