gpt4 book ai didi

blockchain - 是否可以在 genesis.json 中预定义智能合约?

转载 作者:行者123 更新时间:2023-12-03 09:44:32 24 4
gpt4 key购买 nike

我遇到了与 https://ethereum.stackexchange.com/questions/7707/is-it-possible-to-preload-contracts-in-the-genesis-block?rq=1 完全相同的问题

Agian,是否可以通过像这样分配 alloc -> 代码字段来预定义合约,

enter image description here

但是,似乎无论我调用合约中的哪个方法,它总是返回合约本身的字节码,而不管这个方法的逻辑和内容。

enter image description here

这可能是我部署合约的原因:

enter image description here

当我调用 test() 时,获得:

enter image description here这不是一个字符串。

当我调用 test2() 时,获得:

enter image description here这是一个很大的数字。

当我调用 test3(1) 时,得到一个 false,这不是 1 == 1。

我查看了相关的线程,找到了这个,https://ethereum.stackexchange.com/questions/30366/how-does-the-genesis-json-file-define-the-initial-state-of-the-blockchain

看起来存储设置是必要的,但我完全不知道我应该写什么键/值。

那我该如何处理这个案子呢?

最佳答案

However, it seems like no matter which method in the contract I call, it always returns the Bytecode of the contract itself regardless of the logic and content of this method.

这听起来像是你从 solc

中包含了 --bin 而不是 --bin-runtime

您是如何生成要包含的代码的?

--bin代码是在合约创建交易上运行的代码,它返回要包含在合约中的实际代码(即--bin 运行时).

关于blockchain - 是否可以在 genesis.json 中预定义智能合约?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50014286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com