端口号是 在进入终端时 命令行中 --rpcport 8545这里设置的
String url="http://127.0.0.1:8545";
//查看geth客户端版本
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"web3_clientVersion\",\"params\":[],\"id\":67}";
//查看账户
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"eth_accounts\",\"params\":null,\"id\":1}";
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"eth_coinbase\",\"params\":null,\"id\":2}";
//查看账户余额
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBalance\",\"params\":[\"0x41d6d5a2288cc4d56f5090c028eebc39fa9cc210\",\"latest\"],\"id\":3}";
//创建账号
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"personal_newAccount\",\"params\":[\"123123\"],\"id\":4}";
//查看所有账号
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"personal_listAccounts\",\"params\":null,\"id\":5}";
//解锁账户
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"personal_unlockAccount\",\"params\":[\"0x41d6d5a2288cc4d56f5090c028eebc39fa9cc210\",\"123123\"],\"id\":4}";
//交易
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"eth_sendTransaction\",\"params\":[{\"from\":\"0x41d6d5a2288cc4d56f5090c028eebc39fa9cc210\",\"to\": \"0x8ccac9a996281af1c2f1512485ce852319e16cbe\",\"value\":\"0xcddddd\" }],\"id\":5}";
//查询交易信息
// String paramJson="{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionReceipt\",\"params\":[\"0x2e88ea5cd27171c5d9c76971a85b26928149ec700a488d90676c63348c4ea165\"],\"id\":1}";
//调用智能合约
String paramJson = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_sendTransaction\",\"params\":[{\"from\":\"0x9bdfee3a498e9d70ae37161d53e56f6546bc5257\",\"to\": \"0x3d3161f2b674834756692e7662bb418c85c22a66\",\"data\":\"0x867904b40000000000000000000000009bdfee3a498e9d70ae37161d53e56f6546bc5257000000000000000000000000000000000000000000000000000000000000000a\"}],\"id\":67}";
请求时候用post方式请求
String response = doJsonPost(url,paramJson);
System.out.println(response) ;