如何更改Etherscan上的旧实施合同地址?

发布于 2025-02-07 05:36:42 字数 485 浏览 1 评论 0 原文

我使用坚固的合同写了可升级的智能合同,并升级了几次合同。 当我升级智能合约时,更改了实施合同地址。 但是在该地址下,旧的实施合同地址仍然存在。

如何更改或隐藏此旧地址?

I wrote upgradable smart contract using solidity and upgraded contract several time.
When I upgraded smart contract, implementation contract address was changed.
But under that address, the old implementation contract address still remains.

https://rinkeby.etherscan.io/address/0x245dBBE31f33569D3d7F1e0df10c93547c44065D#readProxyContract

enter image description here

How to change or hide this old address?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹过旳痕迹 2025-02-14 05:36:42

特别是一旦将任何东西存储在区块链上,就无法隐藏任何东西。旧地址仍然可以看到。

但是,如果您希望呼叫旧合同应该失败,则可以在智能合约中创建自我毁灭功能,并在更新智能合约并使用新地址部署它时将其调用。

提示 -

  • 始终拥有自我毁灭的智能合约功能
  • ,只要您更新智能合约即将其部署到新地址,请在旧合同地址上调用自我毁灭功能,以销毁它。

自我破坏的语法 -

contract YourContract {
    // State variables
    // Some functions
   
    function destruct(address addr) ownerOnly {
         selfdestruct(addr);
    }
    // The above function sends all ether from the contract to the specified address

}

Particularly you can't hide anything once it is stored on the Blockchain. The old address will still be visible.

But if you want that calling to the old contract should fail, you can simply create a self destruct function inside your smart contract and call it when you have updated the smart contract and deployed it with a new address.

Tip -

  • Always have smart contracts with the self destruct functionality
  • Whenever you update your smart contract i.e deploy it to a new address, call the self destruct function on the old contract address for it to be destroyed.

Syntax for self destruct -

contract YourContract {
    // State variables
    // Some functions
   
    function destruct(address addr) ownerOnly {
         selfdestruct(addr);
    }
    // The above function sends all ether from the contract to the specified address

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文