混音坚固不返回私人以太坊链的结果

发布于 2025-02-03 04:42:46 字数 976 浏览 4 评论 0原文

我刚刚开始学习以太坊和混音,这个问题对您来说似乎很愚蠢。

我尝试在嵌入了混音IDE内部的JavaScript VM上以下代码,并且它的工作原理完全不错,但是它无法返回我早日设置的私有链上的字符串,即使它没有报告任何错误。我使用的坚固代码如下。

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
contract Greeter {

    function greet() external pure returns(string memory) {
        return "Hello, World!";
    }

}

有人可以提供一些我可能出错的想法吗? ps i已设置miner.start(),并使用以下脚本来启动私人链:

geth --datadir data --networkid 18810100026 --port 60000 --rpc  --rpcport 8100 --rpcaddr 0.0.0.0 --bootnodes enode://****73c2e56ed109f7ab559bc0df26e01e4a72c4eef660d0853e8c241a737b43bd7f7da32d22e272fe187f7063d9559691@****:30301 --rpcapi eth,web3,miner,admin,personal,net --rpccorsdomain "*"```

geth version is 1.7.3

在私人链上运行的合同的屏幕截图

I have just started learning ethereum and remix, and this question might seem stupid to you.

I tried following codes on javascript vm embedded inside remix ide, and it works totally fine, but it fails to return the string on a private chain I set up early, even though it does not report any errors. The solidity code I'm using is as follows.

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
contract Greeter {

    function greet() external pure returns(string memory) {
        return "Hello, World!";
    }

}

Can anybody provide some idea where I might go wrong?
P.S. I have set miner.start(), and use following script to start the private chain:

geth --datadir data --networkid 18810100026 --port 60000 --rpc  --rpcport 8100 --rpcaddr 0.0.0.0 --bootnodes enode://****73c2e56ed109f7ab559bc0df26e01e4a72c4eef660d0853e8c241a737b43bd7f7da32d22e272fe187f7063d9559691@****:30301 --rpcapi eth,web3,miner,admin,personal,net --rpccorsdomain "*"```

geth version is 1.7.3

screenshot of contract running on private chain

screenshot of contract running on javascript VM

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

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

发布评论

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

评论(2

唐婉 2025-02-10 04:42:46

我认为有两个事实可能导致这样的错误,

  1. 我没有将geth更新为当前最新版本。
  2. 我没有正确初始化创世纪块。

因此,我进行了两次修改以解决此类问题,

  1. geth更新为1.10.17,
  2. 将两行添加到Genesis JSON文件中,该文件自动生成由Puppeth
    如下所示,
{
  "config": {
    ...
    "byzantiumBlock": 4,
    "constantinopleBlock": 5,
    ...
  },
...

此后解决了问题。

I think there were two fact that might lead to such an error

  1. I did not update the geth to the current latest version.
  2. I did not initialize the genesis block correctly.

So I made two modifications to solve such a problem

  1. Update the geth to 1.10.17
  2. add two lines to the genesis json file automatically generated by puppeth,
    which are as follows
{
  "config": {
    ...
    "byzantiumBlock": 4,
    "constantinopleBlock": 5,
    ...
  },
...

The problem was solved thereafter.

oО清风挽发oО 2025-02-10 04:42:46

我认为您的合同还可以!

我将您的代码复制到Remix 0.23.3上的新合同,然后返回奇迹功能:“您好,世界!”

也许您在另一个版本中使用混音IDE,或者您的IDE具有错误。
我建议您将另一个吹牛用于混音或另一个IDE以实现固体,例如hardhat https://hardhat.org/

我的结果问候:

i think your contract is ok!

i copy your code in to new contract on Remix 0.23.3, and return greet function: "Hello, World!"

Maybe you use remix ide in another version or your ide has bugs.
I suggest you use another brower for remix or another ide for solidity like hardhat https://hardhat.org/

my result for greet:
enter image description here

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