Skip to content

Commit

Permalink
Update doc (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
garyghayrat committed Jun 18, 2024
1 parent 54a0f76 commit 0154774
Show file tree
Hide file tree
Showing 8 changed files with 548 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pages/contracts/contract-interfaces/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"erc5564-interface": "ERC5564Announcer.sol Interface",
"erc6538-interface": "ERC6538Registry.sol Interface"
"erc5564-interface": "IERC5564Announcer.sol",
"erc6538-interface": "IERC6538Registry.sol"
}
55 changes: 55 additions & 0 deletions pages/contracts/contract-interfaces/erc5564-interface.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# IERC5564Announcer

Interface for calling the `ERC5564Announcer` contract, which emits an `Announcement` event to broadcast information about a transaction involving a stealth address. See [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) to learn more.

### Code: [`IERC5564Announcer.sol`](https://github.com/ScopeLift/stealth-address-erc-contracts/blob/b6f7d989b6247f81ceede5d1be2ffb23c1cb39b5/src/interfaces/IERC5564Announcer.sol)

## Functions

### announce

```solidity
function announce(
uint256 schemeId,
address stealthAddress,
bytes memory ephemeralPubKey,
bytes memory metadata
) external
```

Called by integrators to emit an `Announcement` event.

#### Parameters:

| Type | Name | Description |
| --------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). |
| `address` | `stealthAddress` | The computed stealth address for the recipient. |
| `bytes` | `ephemeralPubKey` | Ephemeral public key used by the sender. |
| `bytes` | `metadata` | Arbitrary data to emit with the event. The first byte MUST be the view tag. The remaining metadata can be used freely by the senders. |

## Events

### Announcement

```solidity
event Announcement(
uint256 indexed schemeId,
address indexed stealthAddress,
address indexed caller,
bytes ephemeralPubKey,
bytes metadata
);
```

Emitted when something is sent to a stealth address.

#### Parameters:

| Type | Name | Description |
| --------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). |
| `address` | `stealthAddress` | The computed stealth address for the recipient. |
| `address` | `caller` | The caller of the `announce` function that emitted this event. |
| `bytes` | `ephemeralPubKey` | Ephemeral public key used by the sender to derive the `stealthAddress`. |
| `bytes` | `metadata` | Arbitrary data to emit with the event. The first byte MUST be the view tag. The remaining metadata can be used by the senders as they like. See [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) for recommendations on how to structure this metadata. |
160 changes: 160 additions & 0 deletions pages/contracts/contract-interfaces/erc6538-interface.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# IERC6538Registry

Interface for calling the `ERC6538Registry` contract to map accounts to their stealth meta-addresses. See [ERC-6538](https://eips.ethereum.org/EIPS/eip-6538) to learn more.

### Code: [`IERC6538Registry.sol`](https://github.com/ScopeLift/stealth-address-erc-contracts/blob/b6f7d989b6247f81ceede5d1be2ffb23c1cb39b5/src/interfaces/IERC6538Registry.sol)

## Functions

### registerKeys

```solidity
function registerKeys(uint256 schemeId, bytes calldata stealthMetaAddress) external
```

Sets the caller's stealth meta-address for the given scheme ID.

#### Parameters:

| Type | Name | Description |
| --------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). |
| `bytes` | `stealthMetaAddress` | The stealth meta-address to register. |

### registerKeysOnBehalf

```solidity
function registerKeysOnBehalf(
address registrant,
uint256 schemeId,
bytes memory signature,
bytes calldata stealthMetaAddress
) external
```

Sets the `registrant`'s stealth meta-address for the given scheme ID.

#### Parameters:

| Type | Name | Description |
| --------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `address` | `registrant` | Address of the registrant. |
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). |
| `bytes` | `signature` | A signature from the `registrant` authorizing the registration. |
| `bytes` | `stealthMetaAddress` | The stealth meta-address to register. |

### incrementNonce

```solidity
function incrementNonce() external
```

Increments the nonce of the sender to invalidate existing signatures.

### DOMAIN_SEPARATOR

```solidity
function DOMAIN_SEPARATOR() external view returns (bytes32)
```

Returns the domain separator used in this contract.

### stealthMetaAddressOf

```solidity
function stealthMetaAddressOf(address registrant, uint256 schemeId) external view returns (bytes memory)
```

Returns the stealth meta-address for the given `registrant` and `schemeId`.

#### Parameters:

| Type | Name | Description |
| --------- | ------------ | --------------------------------------------------------------- |
| `address` | `registrant` | The address of the registrant. |
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme. |

#### Return Values:

| Type | Description |
| ------- | ------------------------- |
| `bytes` | The stealth meta-address. |

### ERC6538REGISTRY_ENTRY_TYPE_HASH

```solidity
function ERC6538REGISTRY_ENTRY_TYPE_HASH() external view returns (bytes32)
```

Returns the EIP-712 type hash used in `registerKeysOnBehalf`.

#### Return Values:

| Type | Description |
| --------- | ---------------------- |
| `bytes32` | The EIP-712 type hash. |

### nonceOf

```solidity
function nonceOf(address registrant) external view returns (uint256)
```

Returns the nonce of the given `registrant`.

#### Parameters:

| Type | Name | Description |
| --------- | ------------ | ------------------------------ |
| `address` | `registrant` | The address of the registrant. |

#### Return Values:

| Type | Description |
| --------- | ----------- |
| `uint256` | The nonce. |

## Events

### StealthMetaAddressSet

```solidity
event StealthMetaAddressSet(
address indexed registrant, uint256 indexed schemeId, bytes stealthMetaAddress
);
```

Emitted when a registrant updates their stealth meta-address.

#### Parameters:

| Type | Name | Description |
| --------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `address` | `registrant` | The address of the registrant of the stealth meta-address. |
| `uint256` | `schemeId` | Identifier corresponding to the applied stealth address scheme, e.g., 1 for `secp256k1`, as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). |
| `bytes` | `stealthMetaAddress` | The stealth meta-address. Based on [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564). |

### NonceIncremented

```solidity
event NonceIncremented(address indexed registrant, uint256 newNonce);
```

Emitted when a registrant increments their nonce.

#### Parameters:

| Type | Name | Description |
| --------- | ------------ | --------------------------------------- |
| `address` | `registrant` | The account that incremented the nonce. |
| `uint256` | `newNonce` | The new nonce value. |

## Errors

### ERC6538Registry\_\_InvalidSignature

```solidity
error ERC6538Registry__InvalidSignature();
```

Emitted when an invalid signature is provided to `registerKeysOnBehalf`.
12 changes: 12 additions & 0 deletions pages/contracts/deployments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ The stealth contracts are deployed at the following addresses:
`ERC5564Announcer`: 0x55649E01B5Df198D18D95b5cc5051630cfD45564<br/>
`ERC6538Registry`: 0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538

### Mainnet Networks

| Networks | ERC5564Announcer | ERC6538Registry |
| :----------- | :-----------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: |
| Mainnet | [0x55649E01B5Df198D18D95b5cc5051630cfD45564](https://etherscan.io/address/0x55649E01B5Df198D18D95b5cc5051630cfD45564#code) | [0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538](https://etherscan.io/address/0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538#code) |
| Arbitrum | [0x55649E01B5Df198D18D95b5cc5051630cfD45564](https://arbiscan.io/address/0x55649E01B5Df198D18D95b5cc5051630cfD45564#code) | [0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538](https://arbiscan.io/address/0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538#code) |
| Base | [0x55649E01B5Df198D18D95b5cc5051630cfD45564](https://basescan.org/address/0x55649E01B5Df198D18D95b5cc5051630cfD45564#code) | [0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538](https://basescan.org/address/0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538#code) |
| Gnosis Chain | [0x55649E01B5Df198D18D95b5cc5051630cfD45564](https://gnosisscan.io/address/0x55649E01B5Df198D18D95b5cc5051630cfD45564#code) | [0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538](https://gnosisscan.io/address/0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538#code) |
| Optimism | [0x55649E01B5Df198D18D95b5cc5051630cfD45564](https://optimistic.etherscan.io/address/0x55649E01B5Df198D18D95b5cc5051630cfD45564#code) | [0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538](https://optimistic.etherscan.io/address/0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538#code) |
| Polygon | [0x55649E01B5Df198D18D95b5cc5051630cfD45564](https://polygonscan.com/address/0x55649E01B5Df198D18D95b5cc5051630cfD45564#code) | [0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538](https://polygonscan.com/address/0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538#code) |
| Scroll | [0x55649E01B5Df198D18D95b5cc5051630cfD45564](https://scrollscan.com/address/0x55649E01B5Df198D18D95b5cc5051630cfD45564#code) | [0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538](https://scrollscan.com/address/0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538#code) |

### Ethereum Test Networks

| Networks | ERC5564Announcer | ERC6538Registry |
Expand Down
79 changes: 79 additions & 0 deletions pages/contracts/erc5564-contract.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# ERC5564Announcer.sol

## Overview

The `ERC5564Announcer` contract is designed to facilitate the broadcasting of transactions involving stealth addresses by emitting an `Announcement` event. This event contains relevant information that can be used to reconstruct the transaction and validate its parameters.

### Code: [`ERC5564Announcer.sol`](https://github.com/ScopeLift/stealth-address-erc-contracts/blob/b6f7d989b6247f81ceede5d1be2ffb23c1cb39b5/src/ERC5564Announcer.sol)

## Events

### Announcement

The `Announcement` event is emitted when the `announce` function is called. Here are the key components of this event:

- **schemeId** (`uint256`): Identifier corresponding to the applied stealth address scheme (e.g., `1` for `secp256k1` as specified in [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564)).
- **stealthAddress** (`address`): The computed stealth address for the recipient.
- **caller** (`address`): The address that called the `announce` function.
- **ephemeralPubKey** (`bytes`): Ephemeral public key used by the sender to derive the `stealthAddress`.
- **metadata** (`bytes`): Arbitrary data to emit with the event. The first byte MUST be the view tag. The remaining metadata can be used by the senders as per their requirements (refer to [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) for recommended metadata structure).

#### Event Signature

```solidity
event Announcement(
uint256 indexed schemeId,
address indexed stealthAddress,
address indexed caller,
bytes ephemeralPubKey,
bytes metadata
);
```

## Functions

### announce

The `announce` function is used by integrators to emit the `Announcement` event. It takes the following parameters:

- **schemeId** (`uint256`): Identifier corresponding to the applied stealth address scheme.
- **stealthAddress** (`address`): The computed stealth address for the recipient.
- **ephemeralPubKey** (`bytes`): The ephemeral public key used by the sender.
- **metadata** (`bytes`): Arbitrary data to emit with the event. The first byte MUST be the view tag. The remaining metadata can be used freely by the senders.

#### Function Signature

```solidity
function announce(
uint256 schemeId,
address stealthAddress,
bytes memory ephemeralPubKey,
bytes memory metadata
) external
```

#### Description

When called, this function emits the `Announcement` event with all the parameters supplied to it.

#### Usage

To use the `announce` function, you need to pass the required parameters as per the function signature:

```solidity
contract MyContract {
ERC5564Announcer public announcer;
constructor(address announcerAddress) {
announcer = ERC5564Announcer(announcerAddress);
}
function myAnnounceFunction(uint256 _schemeId, address _stealthAddress, bytes memory _ephemeralPubKey, bytes memory _metadata) public {
announcer.announce(_schemeId, _stealthAddress, _ephemeralPubKey, _metadata);
}
}
```

## Related Links

- [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564)
Loading

0 comments on commit 0154774

Please sign in to comment.