新合同可见性

发布于 2025-01-25 03:21:59 字数 180 浏览 6 评论 0原文

首先,请原谅,因为我开始学习坚固的编程,这个问题对你们大多数人来说肯定是微不足道的,但是我还没有找到任何答案。

当我从另一个内部创建一个简单的智能合约(使用“新”)时,我尝试检查新合同的可见性时,即使我可以从remix iDE中与etherscan(rinkeby)上找到它,我也找不到它。有什么理由吗?

非常感谢您!

first of all, excuse me because I am starting to learn Solidity programming, and this question is surely trivial for most of you, but I haven't found any answer yet.

When I create a simple smart contract from within another one (using "new"), and I try to check the new contract visibility, I cannot find it on etherscan (Rinkeby), even though I can interact with it from within Remix IDE. Is there any reason for that?

Thank you very much in advance!!

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

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

发布评论

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

评论(3

百变从容 2025-02-01 03:21:59

首先,您怎么知道新合同有哪个问题?您可以尝试通过事件发射来记录它,并且混音将在控制台上显示。

其次,您在哪个网络上部署合同?默认情况下,混音使用EVM VM,即某些模仿假网络,它不是公共测试网,只是在您的浏览器中本地运行的东西,含义,您看不到etherscan中。

为了实现这一目标,您必须在部署过程中的环境下拉列表中选择“注入Web3”。

有很多陷阱,但是这是一个很好的指南有关如何连接Metamastk TestNet的好指南。

First, how do you know which address the new contract has? You can try to log it via event emitting and Remix will show it on the console.

Secondly, on which network are you deploying your contract? By default Remix use an EVM VM that some mimic a fake network, it is not a public test net, just something that runs locally in your browser, meaning, you can not see in etherscan.

To achieve this, you have to choose "injected web3" in the environment dropdown during the deployment process.

enter image description here

There are a lot of gotchas but here is a good guide on how to connect your metamastk testnet.

孤者何惧 2025-02-01 03:21:59

当您创建创建其他合同的合同时,它不会创建或您试图说什么都不会部署任何合同
Rinkeby的新合同。

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
contract Account {
    address public owner; 
    constructor(address _owner) {
        owner = _owner; 
    }
}
contract AccountFactory{
    function createAccount(address _owner) public {
        Account account = new Account(_owner);
    }
}

当您部署书面智能合约时,帐户和帐户范围将被部署,您将能够在(Rinkeby)上找到它
因此,每次您达到公共createAccount功能时,都会与已部署的帐户智能合约进行交易
绝对不会为每个功能调用创建帐户智能合约。

看看在这里

when you create Contract that Creates other Contracts,It doesn't create or what you are trying to say that it doesn't deploying any
new contract on Rinkeby.

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
contract Account {
    address public owner; 
    constructor(address _owner) {
        owner = _owner; 
    }
}
contract AccountFactory{
    function createAccount(address _owner) public {
        Account account = new Account(_owner);
    }
}

When you are deploying the written smart contract both Account and AccountFactory will be deployed you will be able to find it on (Rinkeby)
Therefore each time you hit the public createAccount function it's just making an transaction on with interact with the deployed Account smart contract
which will definitely not create Account smart contract again for each function call.

Have a look HERE

同展鸳鸯锦 2025-02-01 03:21:59

谢谢大家!

例如,如果将此代码

    SimpleStorage[] public simpleStorageArray; 

    function createSimpleStorageContract() public {
    SimpleStorage simpleStorage = new SimpleStorage();
    simpleStorageArray.push(simpleStorage);

    }  
       

适用于“部署”合同的新实例(将其地址存储在数组中),则每次我调用该函数时,我们都可以与以存储或检索值或其他方式进行交互,或我的问题之所以出现,是因为我发现应该在etherscan中找到新的“部署”合同的地址(在SimpleSorageArray中包含),但实际上却没有。

Thank you all!

For example, if this piece of code

    SimpleStorage[] public simpleStorageArray; 

    function createSimpleStorageContract() public {
    SimpleStorage simpleStorage = new SimpleStorage();
    simpleStorageArray.push(simpleStorage);

    }  
       

is suposed to "deploy" a new instance of a contract (storing their addresses in an array), each time I call the function, so we can interact with to store or retrieve values, or whatever, my question came because I figured out that the address of the new "deployed" contract (contained in simpleStorageArray) should be found in Etherscan, but it actually does not.

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