current position:Home>Deploy two smart contracts and how to call the functions in one JS

Deploy two smart contracts and how to call the functions in one JS

2022-02-03 22:50:48 Q & A of Denglian community

I deployed two smart contracts in Ganache On , And then there's a JS The beginning of the script has import metaCoinArtifact from "../../build/contracts/Test.json"; This code , It can call a smart contract normally , How to do it in a JS Call the functions of the two contracts respectively .




Take the answer 1:

The first contract can use the way you currently use , like this :

//  Get contract object   getContract1() {    const CoinArtifact = contract(metaCoinArtifact);    CoinArtifact.setProvider(xxxprovider);    return CoinArtifact.deployed();  }

Another contract can be like this :

  getContract2(address) {    const CoinArtifact = contract(metaCoinArtifact);    CoinArtifact.setProvider(xxxprovider);    return CoinArtifact.at(address);    //  Specify the address   }



copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032250465806.html

Random recommended