[Ethereum] How to get contract object using ABI json and address with web3j

abijson-rpcweb3j

I worked with web3js(JavaScript) and used web3.eth.Contract with 2 params (json, address) and successfully got contract object.
Now I started to work with web3j(Java) and don`t understand how I have to work now.
How can I do this ?

Best Answer

I found a solution

I installed epirus wrapper, then I generated java package with command epirus solidity generate

-a=/root/my_json.abi -o=/root/ -p=my_java

(before I changed extension of my file from json to abi). After getting this package, I could use smart contract object with his methods from json file.

Also, after installation of epirus and before generating package I used this commands

JAVA_HOME=$(dirname $( readlink -f $(which java) ))
JAVA_HOME=$(realpath "$JAVA_HOME"/../)
export JAVA_HOME

sudo update-alternatives --config java

Don`t know exactly what they do, but without them I could not use epirus.

To check if epirus ready to generate I used command

epirus -V 

It returns version of wrapper. If not - use two commands above.

Ismael, thank you for the direction)