Infura开发手册
Infura是出色的开放以太坊节点,它提供了标准的RPC API可供开发者 调用。除了支持以太坊,Infura还提供IPFS网关和API,并且提供多个 数字货币交易所的行情信息API。
相关教程: 以太坊开发入门 | 以太坊电商DApp实战 | ERC721通证实战
支持的网络
Infura支持如下的以太坊和IPFS网络的访问点:
注意,请务必使用你的Infura仪表盘 中的项目ID/Project ID来替换以下URL中的YOUR-PROJECT-ID。
网络 | 说明 | URL |
---|---|---|
Mainnet | JSON-RPC over HTTPs | https://mainnet.infura.io/v3/YOUR-PROJECT-ID |
Mainnet | JSON-RPC over websockets | wss://mainnet.infura.io/ws/v3/YOUR-PROJECT-ID |
Ropsten | JSON-RPC over HTTPs | https://ropsten.infura.io/v3/YOUR-PROJECT-ID |
Ropsten | JSON-RPC over websockets | wss://ropsten.infura.io/ws/v3/YOUR-PROJECT-ID |
Rinkeby | JSON-RPC over HTTPs | https://rinkeby.infura.io/v3/YOUR-PROJECT-ID |
Rinkeby | JSON-RPC over websockets | wss://rinkeby.infura.io/ws/v3/YOUR-PROJECT-ID |
Kovan | JSON-RPC over HTTPs | https://kovan.infura.io/v3/YOUR-PROJECT-ID |
Kovan | JSON-RPC over websockets | wss://kovan.infura.io/ws/v3/YOUR-PROJECT-ID |
Görli | JSON-RPC over HTTPs | https://goerli.infura.io/v3/YOUR-PROJECT-ID |
Görli | JSON-RPC over websockets | wss://goerli.infura.io/ws/v3/YOUR-PROJECT-ID |
IPFS | IPFS Gateway | https://ipfs.infura.io/ipfs/ |
IPFS | IPFS API | https://ipfs.infura.io:5001/api/ |
以太坊RPC API - HTTPS/WebSocket
- eth_accounts:查询节点账户
- eth_blockNumber:查询当前区块号
- eth_call:消息调用
- eth_chainId:查询链ID
- eth_estimateGas:估算交易gas用量
- eth_gasPrice:查询当前gas价格
- eth_getBalance:查询账户余额
- eth_getBlockByHash:查询指定哈希的区块数据
- eth_getBlockByNumber:查询指定编号的区块数据
- eth_getBlockTransactionCountByHash:获取指定哈希区块内的交易数量
- eth_getBlocktransactionCountByNumber:获取指定编号区块内的交易数量
- eth_getCode:读取指定地址的代码
- eth_getLogs:查询日志
- eth_getStorageAt:读取指定存储位置的内容
- eth_getTransactionByBlockHashAndIndex:查询指定哈希区块内指定序号的交易
- eth_getTransactionByBlockNumberAndIndex:查询指定编号区块内指定序号的交易
- eth_getTransactionByHash:查询指定哈希的交易
- eth_getTransactionCount:查询指定账号的交易数量
- eth_getTransactionReceipt:查询指定交易的收据
- eth_getUncleByBlockHashAndIndex:查询指定哈希区块的指定序号的叔伯块
- eth_getUncleByBlockNumberAndIndex:查询指定编号区块的制定序号的叔伯块
- eth_getUncleCountByBlockHash:查询指定哈希区块的叔伯数量
- eth_getUncleCountByBlockNumber:查询指定编号区块的叔伯数量
- eth_getWork:查询POW工作
- eth_hashrate:查询哈希速率
- eth_mining:查询挖矿状态
- eth_protocolVersion:查询协议版本
- eth_sendRawTransaction:发送裸交易
- eth_submitWork:提交POW计算
- eth_syncing:查询节点同步状态
- net_listening:查询节点监听状态
- net_peerCount:查询节点已连接的对端节点数量
- net_version:查询当前网络ID
- web3_clientVersion:查询节点版本
以太坊RPC API - 仅Websocket
- eth_newBlockFilter:创建新的区块过滤器
- eth_newFilter:创建新的日志过滤器
- eth_newPendingTransactionFilter:创建新的待定交易过滤器
- eth_getFilterChanges:查询过滤器变化
- eth_getFilterLogs:查询过滤器日志
- eth_uninstallFilter:卸载过滤器
- eth_subscribe:订阅事件
- eth_unsubscribe:取消事件订阅
- parity_subscribe:订阅parity命令
- parity_unsubscribe:取消parity命令订阅
IPFS API
- ipfs block_get
- ipfs block_stat
- ipfs cat
- ipfs dag_get
- ipfs dag_resolve
- ipfs get
- ipfs object_data
- ifps object_get
- ipfs object_stat
- ipfs pin_add
- ipfs version
- ipfs add
- ipfs block_put
- ipfs dag_put
- ipfs object_put