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

SNIP-6 Update #130

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Changes from all 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
59 changes: 53 additions & 6 deletions SNIPS/snip-6.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SH

**Every SNIP-6 compliant account MUST implement the `SRC6` and `SRC5` (from [SNIP-5](./snip-5.md)) interfaces**, and publish both interface ids through `supports_interface`:

**The interface ID for an account is hardcoded to be `0x2ceccef7f994940b3962a6c67e0ba4fcd37df7d131417c604f91e03caecc1cd`** which matches the original account interface. Note that some methods have changed since the first version, but the interface ID will not change to maintain compatibility.

#### Current interface
sgc-code marked this conversation as resolved.
Show resolved Hide resolved

```cairo
/// @title Represents a call to a target contract
/// @param to The target contract address
Expand All @@ -40,25 +44,24 @@ The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SH
struct Call {
to: ContractAddress,
selector: felt252,
calldata: Array<felt252>
calldata: Span<felt252>
}

/// @title SRC-6 Standard Account
trait ISRC6 {
/// @notice Execute a transaction through the account
/// @param calls The list of calls to execute
/// @return The list of each call's serialized return value
fn __execute__(calls: Array<Call>) -> Array<Span<felt252>>;
fn __execute__(calls: Array<Call>);

/// @notice Assert whether the transaction is valid to be executed
/// @param calls The list of calls to execute
/// @return The string 'VALID' is represented as felt when is valid
/// @return The string 'VALID' represented as felt when is valid
fn __validate__(calls: Array<Call>) -> felt252;

/// @notice Assert whether a given signature for a given hash is valid
/// @param hash The hash of the data
/// @param signature The signature to validate
/// @return The string 'VALID' is represented as felt when the signature is valid
/// @return The string 'VALID' represented as felt when the signature is valid
fn is_valid_signature(hash: felt252, signature: Array<felt252>) -> felt252;
}

Expand All @@ -71,6 +74,41 @@ trait ISRC5 {
}
```



#### Legacy interface used to calculate the [SRC5](./snip-5.md) interface ID

```cairo
sgc-code marked this conversation as resolved.
Show resolved Hide resolved
/// @title Represents a call to a target contract
/// @param to The target contract address
/// @param selector The target function selector
/// @param calldata The serialized function parameters
struct Call {
to: ContractAddress,
selector: felt252,
calldata: Array<felt252>
}

/// @title SRC-6 Standard Account
trait ISRC6 {
/// @notice Execute a transaction through the account
/// @param calls The list of calls to execute
/// @return The list of each call's serialized return value
fn __execute__(calls: Array<Call>) -> Array<Span<felt252>>;
sgc-code marked this conversation as resolved.
Show resolved Hide resolved

/// @notice Assert whether the transaction is valid to be executed
/// @param calls The list of calls to execute
/// @return The string 'VALID' is represented as felt when is valid
fn __validate__(calls: Array<Call>) -> felt252;

/// @notice Assert whether a given signature for a given hash is valid
/// @param hash The hash of the data
/// @param signature The signature to validate
/// @return The string 'VALID' is represented as felt when the signature is valid
fn is_valid_signature(hash: felt252, signature: Array<felt252>) -> felt252;
}
```

Notice that, if the signature is valid, the return value for `is_valid_signature` MUST be the short string literal `VALID`.

## Security
Expand All @@ -81,10 +119,19 @@ Wallets are advised not to sign any data unless they know that it includes the a

## Rationale

(To Do...)
This SNIP aims to standardize the interface for accounts on Starknet. While some functions are required by Starknet itself for an account to function, this standard includes additional functionality that enhances an account's interoperability with the broader Starknet ecosystem.
For example, the `is_valid_signature` function provides a standard way for dapps and protocols to verify signatures, making the account compatible with any dapp or protocol that expects this functionality. Adhering to the SNIP-5 also makes an account more easily discoverable and integrable.
While an account on Starknet could function without adhering to this standard, doing so provides significant benefits in terms of interoperability, discoverability, and user experience. Accounts compliant with SNIP-6 can expect better compatibility and integration with the rest of the Starknet ecosystem.
sgc-code marked this conversation as resolved.
Show resolved Hide resolved
At the same time, the standard is designed to be minimal and flexible, allowing for a wide variety of account implementations.

## Backwards Compatibility

As mentioned before the interface ID for an account remains `0x2ceccef7f994940b3962a6c67e0ba4fcd37df7d131417c604f91e03caecc1cd`** which matches the original account interface.

Note that the the current interface id and the legacy one are compatible in the way they can be called.

The latest version of the `__execute__` method returns no data. But older versions used to return the result of the calls. Third parties shouldn't rely on the data being returned.

Currently, multiple accounts are using `bool` as the `is_valid_signature` return value. While in the future we expect that most of the accounts will migrate to this standard, in the meantime, we recommend dapps and protocols using this feature to check for both `true` or `'VALID'`.

## Copyright
Expand Down