4

How can we connect two truffle applications with each other? E.g., if we have two metacoin applications, how can these two communicate with each other?

4

By using the same blockchain you can interact with a single contract. Make sure that the applications use the same contract address by using for example var meta = MetaCoin.at("0x1234..."). You can find out where the contract is deployed with MetaCoin.deployed_address.
The only challenge is to tell the second application where the deployed address of the starting application is. Simplest is to write it into a file.

2

To establish the connection between two applications, you need a smart contract. This smart contract will be deployed at one end . The deploying application will use it as contractname.deployed() to create an instance of contract.
As we know that to access any contract on the blockchain, we need :

  1. Contract's AbiDefinition
  2. Contract Address
Second application will only compile the contract. Thus abiDefinition will be available to second app. And contract address will be provided using contractname.at(contractaddress)in the application.
Thus your both applications can communicate.Let me know any further query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.