Jean Cavallera
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- lip: 14 title: Ownable2Step author: discussions-to: https://discord.gg/E2rJPP4 status: Draft type: LSP created: 2022-09-23 requires: ERC173 --- ## Simple Summary <!--"If you can't explain it simply, you don't understand it well enough." Provide a simplified and layman-accessible explanation of the LIP.--> This standard describes a modified version of [EIP173](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-173.md) that uses a a 2-step process to transfer or renounce ownership of a contract, instead of instant execution. In addition, this standard defines hooks in the form of external calls to: - notify when the new owner of the contract should accept ownership. - notify the previous and new owner when ownership of the contract has been fully transferred. ## Abstract <!--A short (~200 word) description of the technical issue being addressed.--> The particular issue that this implementation of [EIP173](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-173.md) solves is the irreversible nature of transferring or renouncing ownership of a contract. Firstly, because owning the contract allows access to sensitive methods, transferring to the wrong address or renouncing ownership of the contract by accident in a single transaction can be highly dangerous. Having those two processes work in 2 steps substantially reduces the probability of transferring or renouncing ownership of the contract by accident. ## Motivation <!--The motivation is critical for LIPs that want to change the Ethereum protocol. It should clearly explain why the existing protocol specification is inadequate to address the problem that the LIP solves. LIP submissions without sufficient motivation may be rejected outright.--> When ownership of a contract is transferred in a single transaction, the new owner has no choice in wanting to own the contract or not. He is forced to own the contract once the transaction has been completed. Making transfer of ownership a two-step process enables to give a choice for the new owner in deciding if he wants to become the owner of the contract or not. Finally, transferring ownership of the contract in a single transaction does not guarantee that the address behind the new owner (EOA or contract) is controlled. For instance, if the new owner lost its private key or if the new owner is a contract that is in a locked state. Letting the new owner accept ownership of the contract guarantees that the contract is owned by an address (EOA or contract) that can be controlled, and that control over the contract implementing LSP14 will not be lost. ## Specification [ERC165] interface id: `0x94be5999` _This interface id can be used to detect Ownable2Step contracts._ ### Methods Contains the methods from: - [ERC173](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-173.md#specification) (Ownable). *See below for details* #### owner ```solidity function owner() external view returns (address); ``` Returns the `address` of the current contract owner. #### pendingOwner ```solidity function pendingOwner() external view returns (address); ``` Returns the `address` of the upcoming new owner that was initiated by the current owner via `transferOwnership(address)`. *Requirements:* - MUST be `address(0)` if no ownership transfer is in progress. - MUST be set when transferring ownership of the contract via `transferOwnership(address)` to a new `address`. - SHOULD be cleared once the [`pendingOwner()`](#pendingowner) has accepted ownership of the contract. #### transferOwnership ```solidity function transferOwnership(address newOwner) external; ``` Sets the `newOwner` as `pendingOwner()`. To transfer ownership fully of the contract, the pending owner MUST accept ownership via the function `acceptOwnership()`. MUST emit a [`OwnershipTransferredStarted`](#ownershiptransferstarted) event once the new owner was set as `pendingOwner()`. *Requirements:* - MUST only be called by the current `owner()` of the contract. - The `newOwner` MUST NOT be the contract itself `address(this)` #### acceptOwnership ```solidity function acceptOwnership() external; ``` Allows the `pendingOwner()` to become the new owner of the contract. This function MUST be called as the second step (after `transferOwnership(address)`) by the current `pendingOwner()` to finalize the ownership transfer. MUST emit a [`OwnershipTransferred`](https://eips.ethereum.org/EIPS/eip-173#specification) event once the new owner has claimed ownership of the contract. *Requirements:* - MUST only be called by the `pendingOwner()`. #### renounceOwnership ```solidity function renounceOwnership() public; ``` Leaves the contract without an owner. Once ownership of the contract is renounced, it MUST NOT be possible to call the functions restricted to the owner only. Since renouncing ownership is a sensitive operation, it SHOULD be done as a two step process by calling `renounceOwnership(..)` twice. First to initiate the process, second as a confirmation. MUST emit a [`RenounceOwnershipInitiated`](#renounceownershipinitiated) event on the first `renounceOwnership(..)` call. MUST emit [`OwnershipTransferred`](https://eips.ethereum.org/EIPS/eip-173#specification) event after successfully renouncing the ownership. *Requirements:* - MUST be called only by the `owner()` only. - The second call MUST happen AFTER the delay of 100 blocks and within the next 100 blocks from the first `renounceOwnership(..)` call. - If the 200 block has passed, the `renounceOwnership(..)` call phase SHOULD reset the process, and a new one will be initated. ### Events #### OwnershipTransferStarted ```solidity event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); ``` MUST be emitted when the process of transferring owhership of the contract is initiated. _Values:_ - `previousOwner` Address of the current owner of the conract that implements LSP14. - `newOwner` Address that will receive ownership of the contract that implemets LSP14. #### RenounceOwnershipInitiated ```solidity event RenounceOwnershipInitiated(); ``` MUST be emitted when the process of renouncing ownership of the contract is initiated. ### Hooks Every contract that supports the LSP14 standard SHOULD implement these hooks: #### _notifyUniversalReceiver ```solidity function _notifyUniversalReceiver( address universalReceiver, bytes32 typeId, bytes memory data ) ``` Calls the `universalReceiver(..)` function on the `universalReceiver` address in the following situations: - When transferring ownership to the new owner, if the new owner address supports LSP1 InterfaceID, with the parameters below: - `typeId`: keccak256('LSP14OwnershipTransferStarted') - `data`: TBD - When accepting ownership by the new owner, if the old owner address supports LSP1 InterfaceID, with the parameters below: - `typeId`: keccak256('LSP14OwnershipTransferred_SenderNotification') - `data`: TBD - When accepting ownership by the new owner, if the new owner address supports LSP1 InterfaceID, with the parameters below: - `typeId`: keccak256('LSP14OwnershipTransferred_RecipientNotification') - `data`: TBD ## Interface Cheat Sheet ```solidity interface ILSP14 /* is ERC173 */ { event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event RenounceOwnershipInitiated(); function owner() external view returns (address); function pendingOwner() external view returns (address); function transferOwnership(address newOwner) external; // onlyOwner function acceptOwnership() external; function renounceOwnership() external; // onlyOwner } ``` ## Copyright Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). [ERC165]: <https://eips.ethereum.org/EIPS/eip-165> [LSP1-UniversalReceiver]: <./LSP-1-UniversalReceiver.md> [LSP2-ERC725YJSONSchema]: <./LSP-2-ERC725YJSONSchema.md>

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully