智能合约编译abi及java接口
solc ./contract/Market.sol --abi --bin -o ./contract --overwrite
web3j generate solidity -b ./contract/Market.bin -a ./contract/Market.abi -o ./src/main/java -p com.market.contract
合约调用
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProviders("http://localhost:8545"));
var _from = web3.eth.account[0];
var _to = web3.eth.account[1];
var _amount = 50000;
var abi = [....];
var CoinContract = web3.eth.contract(abi);
var contractAddress = "0x...."
var contractInstance = CoinContract.at(contractAddress);
web3.personal.unlockAccount(_from, '123456', (err, res) => {
if (err)
console.log('Error: ', err);
else
contractInstance.send(_to, amount, {from: _from}, (err, res) => {
if (err)
console.log('Error: ', err);
else
console.log('Result: ', res);
});
});