Skip to content

Commit

Permalink
Add contracts to asset folder and update Deployment Method and `Ref…
Browse files Browse the repository at this point in the history
…erence Implementation` sections
  • Loading branch information
garyghayrat committed Mar 14, 2024
1 parent 27c695d commit a8488d3
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ERCS/erc-5564.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,13 @@ The recipient's address and the `viewTag` MUST be included in the announcement e

This ERC is fully backward compatible.

### Deployment Method

The `ERC5564Announcer` contract is deployed at `0x55649E01B5Df198D18D95b5cc5051630cfD45564` using `CREATE2` via the deterministic deployer at `0x4e59b44847b379578588920ca78fbf26c0b4956c` with a salt of `0xd0103a290d760f027c9ca72675f5121d725397fb2f618f05b6c44958b25b4447`.

## Reference Implementation

You can find the implementation of the ERC above in the Specification section.
You can find the implementation of the `ERC5564Announcer` contract [here](../assets/eip-5564/contracts/ERC5564Announcer.sol) and the interface `IERC5564Announcer.sol` [here](../assets/eip-5564/contracts/interfaces/IERC5564Announcer.sol).

## Security Considerations

Expand Down
43 changes: 43 additions & 0 deletions assets/erc-5564/contracts/ERC5564Announcer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity 0.8.23;

/// @notice `ERC5564Announcer` contract to emit 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.
contract ERC5564Announcer {
/// @notice Emitted when something is sent to a stealth address.
/// @param schemeId Identifier corresponding to the applied stealth address scheme, e.g. 1 for
/// secp256k1, as specified in ERC-5564.
/// @param stealthAddress The computed stealth address for the recipient.
/// @param caller The caller of the `announce` function that emitted this event.
/// @param ephemeralPubKey Ephemeral public key used by the sender to derive the `stealthAddress`.
/// @param metadata Arbitrary data to emit with the event. The first byte MUST be the view tag.
/// @dev The remaining metadata can be used by the senders however they like. See
/// [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) for recommendations on how to structure
/// this metadata.
event Announcement(
uint256 indexed schemeId,
address indexed stealthAddress,
address indexed caller,
bytes ephemeralPubKey,
bytes metadata
);

/// @notice Called by integrators to emit an `Announcement` event.
/// @param schemeId Identifier corresponding to the applied stealth address scheme, e.g. 1 for
/// secp256k1, as specified in ERC-5564.
/// @param stealthAddress The computed stealth address for the recipient.
/// @param ephemeralPubKey Ephemeral public key used by the sender.
/// @param metadata Arbitrary data to emit with the event. The first byte MUST be the view tag.
/// @dev The remaining metadata can be used by the senders however they like. See
/// [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) for recommendations on how to structure
/// this metadata.
function announce(
uint256 schemeId,
address stealthAddress,
bytes memory ephemeralPubKey,
bytes memory metadata
) external {
emit Announcement(schemeId, stealthAddress, msg.sender, ephemeralPubKey, metadata);
}
}
41 changes: 41 additions & 0 deletions assets/erc-5564/contracts/interfaces/IERC5564Announcer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity 0.8.23;

/// @notice 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.
interface IERC5564Announcer {
/// @notice Emitted when something is sent to a stealth address.
/// @param schemeId Identifier corresponding to the applied stealth address scheme, e.g. 1 for
/// secp256k1, as specified in ERC-5564.
/// @param stealthAddress The computed stealth address for the recipient.
/// @param caller The caller of the `announce` function that emitted this event.
/// @param ephemeralPubKey Ephemeral public key used by the sender to derive the `stealthAddress`.
/// @param metadata Arbitrary data to emit with the event. The first byte MUST be the view tag.
/// @dev The remaining metadata can be used by the senders however they like. See
/// [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) for recommendations on how to structure
/// this metadata.
event Announcement(
uint256 indexed schemeId,
address indexed stealthAddress,
address indexed caller,
bytes ephemeralPubKey,
bytes metadata
);

/// @notice Called by integrators to emit an `Announcement` event.
/// @param schemeId Identifier corresponding to the applied stealth address scheme, e.g. 1 for
/// secp256k1, as specified in ERC-5564.
/// @param stealthAddress The computed stealth address for the recipient.
/// @param ephemeralPubKey Ephemeral public key used by the sender.
/// @param metadata Arbitrary data to emit with the event. The first byte MUST be the view tag.
/// @dev The remaining metadata can be used by the senders however they like. See
/// [ERC-5564](https://eips.ethereum.org/EIPS/eip-5564) for recommendations on how to structure
/// this metadata.
function announce(
uint256 schemeId,
address stealthAddress,
bytes memory ephemeralPubKey,
bytes memory metadata
) external;
}

0 comments on commit a8488d3

Please sign in to comment.