Web3J is lightweight API that connects to and calls a node through JSON-RPC
https://docs.web3j.io/
- Add dependency
- Start a client
- Connect
HttpService service = new HttpService(DemoSettings.NODE_URL);
Web3j connection = Web3j.build(service);
clientVersion = connection.web3ClientVersion().send().getWeb3ClientVersion();
- Unlock account
- Its still possible, but only over IPC sockets, not over HTTP.
- Or, unlock on server, and just use the account address
https://docs.web3j.io/transactions.html#transaction-mechanisms
- Just call with address - unlock account on server
- Use "PersonalUnlockAccount personalUnlockAccount = web3j.personalUnlockAccount("0x000...", "a password").send();" to unlock
- THIS DOES NOT WORK OVER HTTP!!
- Use wallet
- wallet file is just the key file under .ethereum...keystore...
- can use "web3j wallet" utility to create / update (password) wallet file, or create one from private key
Manually https://docs.web3j.io/transactions.html#transacting-with-contract
Through a smart contract wrapper:
- Install web3jfat jar: download the package, unzip, add to path