0

I'm having some confusion about communication between java application and smart contract. In my scenario, I have 2 geth clients Node1(http://localhost:8545) Node2(http://localhost:8546). A java application1 deploy a smart contract through Node1. I have another java application2 wants to interact with the smart contract(call a function) through Node2; however, java application2 have no information about the smart contract(function name,...), so it is impossible to use the wrapper. How can my application2 interact with the smart contract while I only know about a smart contract address. Is there any geth command to get the ABI detail that I can use from java application2 Or I need to create a seperate P2P network between application1 and application2 for sending ABI. Regards,

EM

0

If nodes are in the same network, it does not matter if you interact with the smart contract from node 1 or node 2. Because the both have the same state.

Blockchain state is synchronised across all get nodes in the network. All nodes will execute all transactions in all blocks with they fetch over peer-to-peer network to arrive in the same local state.

ABI details of the smart contract are part of your application source code, and not distributed over blockchain.

2
  • thanks you, but I think you misunderstood my question. Yes my application2 can invoke a function of a smart contract, but only when it knows what is the name of the function and the arguments. From Java application, only when you have a source code of the smart contract, you can invoke them by doing like sc.function(). In this situation, the java application2 does not contain any information of the smart contract but its address, how can it invoke a function inside a smart contract? – Eth.Cat Dec 8 '20 at 14:39
  • If your application 2 does not have ABI information available for the smart contract it cannot interact with that particular contract, period. So you need to have ABI data embedded in the application source code files. – Mikko Ohtamaa Dec 8 '20 at 20:52

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.