From a8488d3f1be1c1014d8b4097e8a9aca56eba0f43 Mon Sep 17 00:00:00 2001 From: garyghayrat Date: Fri, 8 Mar 2024 14:32:49 -0500 Subject: [PATCH] Add contracts to asset folder and update `Deployment Method` and `Reference Implementation` sections --- ERCS/erc-5564.md | 6 ++- .../erc-5564/contracts/ERC5564Announcer.sol | 43 +++++++++++++++++++ .../interfaces/IERC5564Announcer.sol | 41 ++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 assets/erc-5564/contracts/ERC5564Announcer.sol create mode 100644 assets/erc-5564/contracts/interfaces/IERC5564Announcer.sol diff --git a/ERCS/erc-5564.md b/ERCS/erc-5564.md index 355b4389825..5d3fea82dbf 100644 --- a/ERCS/erc-5564.md +++ b/ERCS/erc-5564.md @@ -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 diff --git a/assets/erc-5564/contracts/ERC5564Announcer.sol b/assets/erc-5564/contracts/ERC5564Announcer.sol new file mode 100644 index 00000000000..9a9a26cd6c6 --- /dev/null +++ b/assets/erc-5564/contracts/ERC5564Announcer.sol @@ -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); + } +} diff --git a/assets/erc-5564/contracts/interfaces/IERC5564Announcer.sol b/assets/erc-5564/contracts/interfaces/IERC5564Announcer.sol new file mode 100644 index 00000000000..77de454b1da --- /dev/null +++ b/assets/erc-5564/contracts/interfaces/IERC5564Announcer.sol @@ -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; +}