简体   繁体   English

如何部署两个相互继承的智能合约一起测试网络?

[英]How to deploy two smart contracts that inherit from each other to test network together?

I have two smarts contracts我有两个智能合约

I working in remix IDE and when I click "Deploy", I can deploy only one smart contract.我在混音 IDE 中工作,当我单击“部署”时,我只能部署一个智能合约。 And when I copy ABI, I can copy only one ABI from one contract.当我复制 ABI 时,我只能从一份合约中复制一份 ABI。

Is there a way to deploy this two contracts together, or should I deploy them seperatly?有没有办法将这两个合同一起部署,或者我应该单独部署它们? And if I will deploy them seperatly how numberTwo contract will find where is numberOne contract?如果我将单独部署它们,numberTwo 合约将如何找到 numberOne 合约在哪里?

Thank you.谢谢你。

pragma solidity ^0.4.25;
contract numberOne{
}
contract numberTwo is numberOne{
}

The way you wrote it is that your numberTwo contract inherit numberOne so you don't need to deploy the first one separately.你写它的方式是你的 numberTwo 合约继承 numberOne 所以你不需要单独部署第一个。

But if you actually wanna deploy them separately you can do it like this.但如果你真的想单独部署它们,你可以这样做。 Just deploy them one by one and then connect the first one to the second one using the address of the first one.只需一个一个地部署它们,然后使用第一个的地址将第一个连接到第二个。

contract NumberOne {
 uint256 public someData = 256;
}

contract NumberTwo {

  NumberOne numberOneContract;

  function initNumberOne(address _address) public {
    numberOneContract = NumberOne(_address);            
  }

  function getSomeData() view public returns (uint256) {
    return numberOneContract.someData();
  }

}

I just made it.我刚刚成功了。 If simply deploy numberTwo contract that inherit from numberOne contract first, it will automaticly deploy two contracts.如果简单地先部署继承自 numberOne 合约的 numberTwo 合约,它会自动部署两个合约。 And if I will copy numberTwo contract's ABI it will have ABI from numberOne contract as well.如果我要复制 numberTwo 合同的 ABI,它也会有来自 numberOne 合同的 ABI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何一起部署多个应用程序 - How to deploy multiple applications together 在rinkeby测试网络上部署固态智能合约的问题 - issues deploying solidity smart contract to rinkeby test network 如何测试 maven 部署? - How to test maven deploy? 通过应用程序访问在Ropsten网络上部署的智能合约 - Access a smart contract that is deployed on the Ropsten network from an App 如何在不实际安装的情况下在网络上部署MSI - How to deploy MSI on a network without actually installing it 开发后如何部署神经网络? - How to deploy a neural network after developing it? 如何测试和部署分布式应用程序? - How to test and deploy distributed applications? 如何将通用的JavaScript和图像部署到两个不同的EAR,而又不必维护每个文件的两个版本 - How can one deploy common JavaScript and images to two different EARs while not having to maintain two versions of each file 如何在 local.network 上部署 React + Express 应用程序? - How to deploy a React + Express app on a local network? React.js - 如何独立或一起部署客户端和服务器? - React.js - How to deploy client and server independently or together?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM