更新实时智能合约 [英] Updating a live smart contract

查看:66
本文介绍了更新实时智能合约的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个智能合约,其中包含一些其他智能合约的地址,并且在其中进行了硬编码.例如.也许我的合同包含一些外部增产农业金库的地址,并定期向其中存入一些余额.

现在让我说,我想更新该地址列表并进行迁移,而又不影响当前合同的运作..最好的方法是什么?

解决方案

以太坊字节码是不可变的,因此简单的答案是:您无法更新硬编码的地址.您必须创建一个新合同,这一次将地址保存到变量中,以便以后更新.


但是,如果您可以 selfdestruct 您的合同并持有私钥到部署者地址,则似乎有一种方法重新部署自销合同(使用不同的字节码)).我只读了几篇有关此技术的文章,并且没有使用该技术的实际经验,但这对您来说可能是一个很好的起点,并且可以帮助您更深入地进行研究:

https://medium.com/@jason.carver/defend-against-wild-magic-in-the-next-ethereum-upgrade-b008247839d2

If I have a smart contract that has the addresses of some other smart contracts hardcoded inside it. E.g. maybe my contract has the addresses of some external yield farming vaults that it periodically deposits some balances to.

Now lets say that I want to update that list of addresses and remigrate it without upsetting the operation of the current contract.. what is the best way to do it ?

解决方案

Ethereum bytecode is immutable, so the simple answer is: You can't update the hardcoded addresses. You'll have to create a new contract and this time save the addresses into variables that you can update later.


However, if you can selfdestruct your contract and hold private key to the deployer address, there seems to be a way to redeploy a selfdestruct contract (with a different bytecode). I've only read few articles about it and don't have actual experience with this technique, but this might be a good starting point for you and help you to dig deeper:

https://medium.com/@jason.carver/defend-against-wild-magic-in-the-next-ethereum-upgrade-b008247839d2

这篇关于更新实时智能合约的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆