- 第 1 章 区块链
- 第 2 章 以太坊
- 第 3 章 以太坊私链入门
- 第 4 章 以太坊网络
- 第 5 章 geth v1.8.16 命令详解
- 第 6 章 Wallet
- 第 7 章 Token
- 第 8 章 智能合约语言 Solidity v0.5.0
- 第 9 章 Truffle v4.1.8 开发框架
- 第 10 章 web3.js - 1.0.0
- 第 11 章 web3j v3.4.0 - Jave Client
- 11.2. 启动以太坊
- 11.3. Maven pom.xml 文件
- 11.4. Java 与 Solidity 数据类型映射关系
- 11.5. 常量
- 11.6. 连接到服务器获取版本号
- 11.7. 获得以太坊状态信息
- 11.8. 单位转换
- 11.9. 账号管理
- 11.10. Credentials
- 11.11. 交易
- 11.12. 钱包
- 11.13. 智能合约
- 11.14. ERC20合约
- 11.15. Infura
- 11.16. 助记词
- 11.17. 过滤器 (Filter)
- 11.18. Subscription
- 11.19. 解锁账号
- 11.20. IBAN (International Bank Account Number)
- 11.21. Springboot with Ethereum (web3j)
- 第 12 章 web3.py - A python interface for interacting with the Ethereum blockchain and ecosystem.
- 第 14 章 Ethereum Developer APIs
- 第 15 章 infura
- 第 16 章 以太坊案例
- 第 17 章 FAQ
- 17.3. Error: authentication needed: password or unlock
- 17.4. 新增节点后不生效
- 17.5. Unhandled rejection Error: Returned error: The method personal_unlockAccount does not exist/is not available
- 17.6. Error: exceeds block gas limit
- 17.7. Migrations.sol:11:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(…) { … }" instead.
- 17.8. Exception in thread "main" rx.exceptions.OnErrorNotImplementedException: Invalid response received: okhttp3.internal.http.RealResponseBody@6c25e6c4
- 17.9. 旧版本 Remix(browser-solidity) 本地安装
- 第 18 章 Hyperledger Fabric v2.0.0
- 第 19 章 Hyperledger Fabric 运维
- 第 20 章 Chaincode 链码(智能合约)
- 第 21 章 Hyperledger Fabric Client SDK for Node.js
- 第 22 章 fabric-sdk-java
- 第 24 章 已知 Hyperledger 落地案例
- 第 25 章 Fabric Command
- 第 26 章 Fabric FAQ
- 第 27 章 IPFS(InterPlanetary File System,星际文件系统)
- 第 28 章 IPFS 命令
- 第 29 章 IPFS WebUI
- 第 30 章 IPFS 集群配置
- 第 31 章 IPFS API
- 第 32 章 IPFS Faq
- 第 33 章 EOS
- 第 34 章 EOS 安装
- 第 35 章 CLEOS
- 第 36 章 智能合约开发
- 第 37 章 EOS Dapp 开发
- 第 38 章 FAQ
- 第 39 章 BaaS (Blockchain as a Service) 平台
- 第 40 章 BitCoin
- 第 41 章 其他区块链相关
- 附录 1. 附录
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
14.2. 账号
14.2. 账号
14.2.1. 余额
获得账号的余额
https://api.etherscan.io/api?module=account&action=balance&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&tag=latest&apikey=JFZWPE88I3TZFZWXKVHJ32INUIYQRRINJ9
14.2.2. 查询区块
http://api.etherscan.io/api?module=account&action=txlist&address=0x3e827461Cc53ed7c75A29187CfF39629FCAE3661&startblock=0&endblock=99999999&sort=asc&apikey=RT5JW37AKEZVSW3C91Z86IGI2FF7JDPF1N
Spring boot 2.0.2 实现交易记录查询
package cn.netkiller.api.restful; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @RestController public class TransactionsRestController { private static final Logger logger = LoggerFactory.getLogger(TransactionsRestController.class); private static final String url = "http://api.etherscan.io/api?module={module}&action={action}&address={address}&startblock={startblock}&endblock={endblock}&sort={sort}&apikey={apikey}"; @Autowired public TestRestController() { // TODO Auto-generated constructor stub } @GetMapping("/block/{startblock}/{endblock}/{address}") public TransactionsResponse block(@PathVariable String startblock, @PathVariable String endblock, @PathVariable String address) { return this.getTransactionsByAddress(startblock, endblock, address); } private TransactionsResponse getTransactionsByAddress(String startblock, String endblock, String address) { Map<String, String> params = new HashMap<String, String>(); params.put("module", "account"); params.put("action", "txlist"); params.put("address", address); params.put("startblock", startblock); params.put("endblock", endblock); params.put("sort", "asc"); params.put("apikey", "RT5JW37AKEZVSW3C91Z86IGI2FF7JDPF1N"); RestTemplate restTemplate = new RestTemplate(); TransactionsResponse result = restTemplate.getForObject(url, TransactionsResponse.class, params); logger.info(params.toString()); logger.info(result.toString()); return result; } } class Transactions { private String blockNumber; private String timeStamp; private String hash; private String nonce; private String blockHash; private String transactionIndex; private String from; private String to; private String value; private String gas; private String gasPrice; private String isError; private String txreceipt_status; private String input; private String contractAddress; private String cumulativeGasUsed; private String gasUsed; private String confirmations; public Transactions() { } public String getBlockNumber() { return blockNumber; } public void setBlockNumber(String blockNumber) { this.blockNumber = blockNumber; } public String getTimeStamp() { return timeStamp; } public void setTimeStamp(String timeStamp) { this.timeStamp = timeStamp; } public String getHash() { return hash; } public void setHash(String hash) { this.hash = hash; } public String getNonce() { return nonce; } public void setNonce(String nonce) { this.nonce = nonce; } public String getBlockHash() { return blockHash; } public void setBlockHash(String blockHash) { this.blockHash = blockHash; } public String getTransactionIndex() { return transactionIndex; } public void setTransactionIndex(String transactionIndex) { this.transactionIndex = transactionIndex; } public String getFrom() { return from; } public void setFrom(String from) { this.from = from; } public String getTo() { return to; } public void setTo(String to) { this.to = to; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public String getGas() { return gas; } public void setGas(String gas) { this.gas = gas; } public String getGasPrice() { return gasPrice; } public void setGasPrice(String gasPrice) { this.gasPrice = gasPrice; } public String getIsError() { return isError; } public void setIsError(String isError) { this.isError = isError; } public String getTxreceipt_status() { return txreceipt_status; } public void setTxreceipt_status(String txreceipt_status) { this.txreceipt_status = txreceipt_status; } public String getInput() { return input; } public void setInput(String input) { this.input = input; } public String getContractAddress() { return contractAddress; } public void setContractAddress(String contractAddress) { this.contractAddress = contractAddress; } public String getCumulativeGasUsed() { return cumulativeGasUsed; } public void setCumulativeGasUsed(String cumulativeGasUsed) { this.cumulativeGasUsed = cumulativeGasUsed; } public String getGasUsed() { return gasUsed; } public void setGasUsed(String gasUsed) { this.gasUsed = gasUsed; } public String getConfirmations() { return confirmations; } public void setConfirmations(String confirmations) { this.confirmations = confirmations; } @Override public String toString() { return "Transactions [blockNumber=" + blockNumber + ", timeStamp=" + timeStamp + ", hash=" + hash + ", nonce=" + nonce + ", blockHash=" + blockHash + ", transactionIndex=" + transactionIndex + ", from=" + from + ", to=" + to + ", value=" + value + ", gas=" + gas + ", gasPrice=" + gasPrice + ", isError=" + isError + ", txreceipt_status=" + txreceipt_status + ", input=" + input + ", contractAddress=" + contractAddress + ", cumulativeGasUsed=" + cumulativeGasUsed + ", gasUsed=" + gasUsed + ", confirmations=" + confirmations + "]"; } } class TransactionsResponse { private String status; private String message; private List<Transactions> result = new ArrayList<Transactions>(); public TransactionsResponse() { } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public List<Transactions> getResult() { return result; } public void setResult(List<Transactions> result) { this.result = result; } @Override public String toString() { return "TransactionsResponse [status=" + status + ", message=" + message + ", result=" + result + "]"; } }
14.2.3. 查询区块
http://api.etherscan.io/api?module=account&action=txlistinternal&address=0x3e827461Cc53ed7c75A29187CfF39629FCAE3661&startblock=0&endblock=99999999&sort=asc&apikey=RT5JW37AKEZVSW3C91Z86IGI2FF7JDPF1N
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论