shivangi
    • 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
    Selfdestruct: A cleanup feature considered for Shanghai The latest Ethereum Core Devs [meeting](https://www.youtube.com/watch?v=ZZx7d14vE10) took place on 10th November, Thursday. The meeting set a stage to discuss Shanghai EIPs, particularly proposals to include EIP-1153, 2537 and 2294 among others. Apart from these there were other important EIPs that were discussed with regards to [Shanghai](https://etherworld.co/2022/10/25/shandong-pre-shanghai-testnet/) that included a conversation around Selfdestruct function. But before finalizing any decision on whether to include or exclude EIP-4758, Andrew Ashkhmin from Eth Cat herders asked Ethereum Foundation to put a blogpost on Selfdestruct to indicate that the community is serious about considering the position of the EIP-4758. Such that any [DApp](https://etherworld.co/2018/02/05/what-are-dapps-and-which-are-the-best-ones-to-use-in-2018/) developer who rely on selfdestruct functionality should come up with their use cases. Only then can the developers can think about the mitigations. Selfdestruct is basically a term used to free up space on blockchain by clearing all smart contracts. Selfdestruct is by far the only way to remove the contract from Ethereum. But recently, Developer MariusVanDerWijden [proposed](https://twitter.com/vdWijden/status/1574314890923212802) to add [EIP-4758](https://eips.ethereum.org/EIPS/eip-4758) to Shanghai that suggests to deactivate selfdestruct. He raised an objection by saying that the EIP-4758 changes the semantics of the SELFDESTRUCT opcode and asked to turn it into a SENDALL which sends the balance of the contract to a receiver. Basically the argument is that selfdestruct require to bring changes to code and removing storage. Going ahead, the future of Verkle trees make selfdestruct function incompatible. EIP-4758 brings that change. The proposal advises disabling the function as a requirement for statelessness. Before moving forward and locking a decision on the position of selfdestruct functionality it is important to understand about selfdestruct first. ## What is Selfdestruct and why we need it? Selfdestruct is a term provided by [Ethereum](https://etherworld.co/2017/08/13/a-complete-guide-to-understand-ethereum-for-beginners/) to describe termination of a contract. It requires making changes to the state of an account, particularly by removing all code and storage. This function is used whenever an emergency occurs like in case of an attack. Selfdestruct function helps developers to remove [smart contracts](https://etherworld.co/2017/09/18/smart-contract-an-introduction/) from the [blockchain](https://etherworld.co/2017/02/08/blockchain-beginners-guide-part-1/) and transfer Ether balance to whatever address they specify. The Ethereum blockchain technology provides an immutability feature for smart contracts. This means that all of the smart contracts are self-executed and cannot be changed after it is deployed on the blockchain. However this makes the blockchain prone to attacks as well because a [smart contract](https://etherworld.co/2017/06/05/minereum-the-first-self-mining-smart-contract/) can be executed by anyone on the permission-less blockchain. Secondly, all the data stored on the blockchain, transactions, and bytecode of [smart contracts](https://etherworld.co/2017/09/18/smart-contract-an-introduction/) are visible to the public, which makes smart contracts become attractive targets for attackers. One such case happened in the year 2016 after which the community realised to built a feature like selfdestruct. It was the time when [decentralised organisations (DAOs)](https://etherworld.co/2018/02/05/what-are-dapps-and-which-are-the-best-ones-to-use-in-2018/) were in their growing stage. DAO refers to Decentralized Autonomous Organization that operates through smart contracts. In the year 2016 an unknown attacker extracted 3.6 million Ether from a decentralized fund called TheDAO which was built by a few members of the Ethereum community. It pointed out the flaw in its code that allowed attacker to drain funds from the main platform. A loophole in the coding had led the attacker to ‘ask’ the smart contract [(DAO)]() to return Ether multiple times before the smart contract could update its balance. The attack continued for days due to the immutability feature of smart contracts. There was no way to destroy a contract at that time. Therefore the DAO developers thought it was right to fork the entire blockchain at that time to further prevent such attack and exploitation. To come up with a solution, selfdestruct was designed to created a protective shield from security threats. It was first called as ‘suicide function’ but later renamed as selfdestrcut. It is important to note that selfdestructing the smart contract is not the same as deleting data from your hard disk. Imagine you have created a smart contract. It contains a few Ethers but now you do not want them or maybe there is a bug in it. In this case, one can selfdestrcut the smart contract by self destructing the address is more convenient as it cause far less gas fees. Keep in mind that even if a smart contract is removed by selfdestruct it still remain a part of blockchain’s history. Also, if someone sends Ether to the removed contracts, the ETH is lost. ##How selfdestruct is used by the developers? Selfdestruct function is used by developers for a range of purposes. Developers mainly use selfdestruct function to make smart contract code more secure by upgrading the smart contracts. It is useful to clean up unused contracts and transfer Ethereum balance. Let us understand by an example. The ERC-20 framework is the implementation of standard API for fungible tokens on Ethereum within smart contracts. It is a standard interface for tokens. Any token that does not interface with the [ERC-20](https://etherworld.co/2018/03/28/coinbase-announces-support-to-erc-20/) standard will have difficulty interacting with other contracts. In such a case, developers will not make changes in the current contract or upgrade it. Instead, they will build a new contract with new required functionalities. Further, according to data collected by 2021 [selfdestrcut smart contract report](https://arxiv.org/pdf/2005.07908.pdf#:~:text=On%20the%20one%20hand%2C%20using,an%20attack%20vector%20for%20attackers), about 55% respondents use selfdestruct to stop the contracts when security vulnerabilities are detected in their contracts. Around 33.33% use it to clean up the blockchain. 27.27% use it for transferring Ethers. On the other hand 12%, 6% and 3% of the respondents use selfdestrct feature for upgrading contract, business requirement and gas refund respectively. CONCLUSION

    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