UNPKG

@etclabscore/ethereum-json-rpc

Version:

450 lines 162 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.EthereumJSONRPC = void 0; // Code generated by @open-rpc/generator DO NOT EDIT. const client_js_1 = require("@open-rpc/client-js"); const lodash_1 = __importDefault(require("lodash")); const schema_utils_js_1 = require("@open-rpc/schema-utils-js"); class EthereumJSONRPC { constructor(options) { /** * current client version */ // tslint:disable-next-line:max-line-length this.web3_clientVersion = (...params) => { return this.request("web3_clientVersion", params); }; /** * Hashes data */ // tslint:disable-next-line:max-line-length this.web3_sha3 = (...params) => { return this.request("web3_sha3", params); }; /** * returns listening status */ // tslint:disable-next-line:max-line-length this.net_listening = (...params) => { return this.request("net_listening", params); }; /** * number of peers */ // tslint:disable-next-line:max-line-length this.net_peerCount = (...params) => { return this.request("net_peerCount", params); }; /** * Network identifier associated with network */ // tslint:disable-next-line:max-line-length this.net_version = (...params) => { return this.request("net_version", params); }; /** * Returns the number of most recent block. */ // tslint:disable-next-line:max-line-length this.eth_blockNumber = (...params) => { return this.request("eth_blockNumber", params); }; /** * Executes a new message call (locally) immediately without creating a transaction on the block chain. */ // tslint:disable-next-line:max-line-length this.eth_call = (...params) => { return this.request("eth_call", params); }; /** * Returns the currently configured chain id */ // tslint:disable-next-line:max-line-length this.eth_chainId = (...params) => { return this.request("eth_chainId", params); }; /** * Returns the client coinbase address. */ // tslint:disable-next-line:max-line-length this.eth_coinbase = (...params) => { return this.request("eth_coinbase", params); }; /** * Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance. */ // tslint:disable-next-line:max-line-length this.eth_estimateGas = (...params) => { return this.request("eth_estimateGas", params); }; /** * Returns the current price per gas in wei */ // tslint:disable-next-line:max-line-length this.eth_gasPrice = (...params) => { return this.request("eth_gasPrice", params); }; /** * Returns Ether balance of a given or account or contract */ // tslint:disable-next-line:max-line-length this.eth_getBalance = (...params) => { return this.request("eth_getBalance", params); }; /** * Gets a block for a given hash */ // tslint:disable-next-line:max-line-length this.eth_getBlockByHash = (...params) => { return this.request("eth_getBlockByHash", params); }; /** * Gets a block for a given number */ // tslint:disable-next-line:max-line-length this.eth_getBlockByNumber = (...params) => { return this.request("eth_getBlockByNumber", params); }; /** * Returns the number of transactions in a block from a block matching the given block hash. */ // tslint:disable-next-line:max-line-length this.eth_getBlockTransactionCountByHash = (...params) => { return this.request("eth_getBlockTransactionCountByHash", params); }; /** * Returns the number of transactions in a block from a block matching the given block number. */ // tslint:disable-next-line:max-line-length this.eth_getBlockTransactionCountByNumber = (...params) => { return this.request("eth_getBlockTransactionCountByNumber", params); }; /** * Returns code at a given contract address */ // tslint:disable-next-line:max-line-length this.eth_getCode = (...params) => { return this.request("eth_getCode", params); }; /** * Polling method for a filter, which returns an array of logs which occurred since last poll. */ // tslint:disable-next-line:max-line-length this.eth_getFilterChanges = (...params) => { return this.request("eth_getFilterChanges", params); }; /** * Returns an array of all logs matching filter with given id. */ // tslint:disable-next-line:max-line-length this.eth_getFilterLogs = (...params) => { return this.request("eth_getFilterLogs", params); }; /** * Returns raw transaction data of a transaction with the given hash. */ // tslint:disable-next-line:max-line-length this.eth_getRawTransactionByHash = (...params) => { return this.request("eth_getRawTransactionByHash", params); }; /** * Returns raw transaction data of a transaction with the block hash and index of which it was mined. */ // tslint:disable-next-line:max-line-length this.eth_getRawTransactionByBlockHashAndIndex = (...params) => { return this.request("eth_getRawTransactionByBlockHashAndIndex", params); }; /** * Returns raw transaction data of a transaction with the block number and index of which it was mined. */ // tslint:disable-next-line:max-line-length this.eth_getRawTransactionByBlockNumberAndIndex = (...params) => { return this.request("eth_getRawTransactionByBlockNumberAndIndex", params); }; /** * Returns an array of all logs matching a given filter object. */ // tslint:disable-next-line:max-line-length this.eth_getLogs = (...params) => { return this.request("eth_getLogs", params); }; /** * Gets a storage value from a contract address, a position, and an optional blockNumber */ // tslint:disable-next-line:max-line-length this.eth_getStorageAt = (...params) => { return this.request("eth_getStorageAt", params); }; /** * Returns the information about a transaction requested by the block hash and index of which it was mined. */ // tslint:disable-next-line:max-line-length this.eth_getTransactionByBlockHashAndIndex = (...params) => { return this.request("eth_getTransactionByBlockHashAndIndex", params); }; /** * Returns the information about a transaction requested by the block number and index of which it was mined. */ // tslint:disable-next-line:max-line-length this.eth_getTransactionByBlockNumberAndIndex = (...params) => { return this.request("eth_getTransactionByBlockNumberAndIndex", params); }; /** * Returns the information about a transaction requested by transaction hash. */ // tslint:disable-next-line:max-line-length this.eth_getTransactionByHash = (...params) => { return this.request("eth_getTransactionByHash", params); }; /** * Returns the number of transactions sent from an address */ // tslint:disable-next-line:max-line-length this.eth_getTransactionCount = (...params) => { return this.request("eth_getTransactionCount", params); }; /** * Returns the receipt information of a transaction by its hash. */ // tslint:disable-next-line:max-line-length this.eth_getTransactionReceipt = (...params) => { return this.request("eth_getTransactionReceipt", params); }; /** * Returns information about a uncle of a block by hash and uncle index position. */ // tslint:disable-next-line:max-line-length this.eth_getUncleByBlockHashAndIndex = (...params) => { return this.request("eth_getUncleByBlockHashAndIndex", params); }; /** * Returns information about a uncle of a block by hash and uncle index position. */ // tslint:disable-next-line:max-line-length this.eth_getUncleByBlockNumberAndIndex = (...params) => { return this.request("eth_getUncleByBlockNumberAndIndex", params); }; /** * Returns the number of uncles in a block from a block matching the given block hash. */ // tslint:disable-next-line:max-line-length this.eth_getUncleCountByBlockHash = (...params) => { return this.request("eth_getUncleCountByBlockHash", params); }; /** * Returns the number of uncles in a block from a block matching the given block number. */ // tslint:disable-next-line:max-line-length this.eth_getUncleCountByBlockNumber = (...params) => { return this.request("eth_getUncleCountByBlockNumber", params); }; /** * Returns the account- and storage-values of the specified account including the Merkle-proof. */ // tslint:disable-next-line:max-line-length this.eth_getProof = (...params) => { return this.request("eth_getProof", params); }; /** * Returns the hash of the current block, the seedHash, and the boundary condition to be met ('target'). */ // tslint:disable-next-line:max-line-length this.eth_getWork = (...params) => { return this.request("eth_getWork", params); }; /** * Returns the number of hashes per second that the node is mining with. */ // tslint:disable-next-line:max-line-length this.eth_hashrate = (...params) => { return this.request("eth_hashrate", params); }; /** * Returns true if client is actively mining new blocks. */ // tslint:disable-next-line:max-line-length this.eth_mining = (...params) => { return this.request("eth_mining", params); }; /** * Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges. */ // tslint:disable-next-line:max-line-length this.eth_newBlockFilter = (...params) => { return this.request("eth_newBlockFilter", params); }; /** * Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges. */ // tslint:disable-next-line:max-line-length this.eth_newFilter = (...params) => { return this.request("eth_newFilter", params); }; /** * Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges. */ // tslint:disable-next-line:max-line-length this.eth_newPendingTransactionFilter = (...params) => { return this.request("eth_newPendingTransactionFilter", params); }; /** * Returns the transactions that are pending in the transaction pool and have a from address that is one of the accounts this node manages. */ // tslint:disable-next-line:max-line-length this.eth_pendingTransactions = (...params) => { return this.request("eth_pendingTransactions", params); }; /** * Returns the current ethereum protocol version. */ // tslint:disable-next-line:max-line-length this.eth_protocolVersion = (...params) => { return this.request("eth_protocolVersion", params); }; /** * Creates new message call transaction or a contract creation for signed transactions. */ // tslint:disable-next-line:max-line-length this.eth_sendRawTransaction = (...params) => { return this.request("eth_sendRawTransaction", params); }; /** * Used for submitting mining hashrate. */ // tslint:disable-next-line:max-line-length this.eth_submitHashrate = (...params) => { return this.request("eth_submitHashrate", params); }; /** * Used for submitting a proof-of-work solution. */ // tslint:disable-next-line:max-line-length this.eth_submitWork = (...params) => { return this.request("eth_submitWork", params); }; /** * Returns an object with data about the sync status or false. */ // tslint:disable-next-line:max-line-length this.eth_syncing = (...params) => { return this.request("eth_syncing", params); }; /** * Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additionally Filters timeout when they aren't requested with eth_getFilterChanges for a period of time. */ // tslint:disable-next-line:max-line-length this.eth_uninstallFilter = (...params) => { return this.request("eth_uninstallFilter", params); }; if (options.transport === undefined || options.transport.type === undefined) { throw new Error("Invalid constructor params"); } const { type, host, port, protocol } = options.transport; let path = options.transport.path || ""; if (path && path[0] !== "/") { path = "/" + path; } switch (type) { case 'http': case 'https': this.transport = new client_js_1.HTTPTransport((protocol || type) + "://" + host + ":" + port + path); break; case 'websocket': this.transport = new client_js_1.WebSocketTransport((protocol || "ws://") + host + ":" + port + path); break; case 'postmessageiframe': this.transport = new client_js_1.PostMessageIframeTransport(protocol + "://" + host + ":" + port + path); break; case 'postmessagewindow': this.transport = new client_js_1.PostMessageWindowTransport(protocol + "://" + host + ":" + port + path); break; default: throw new Error("unsupported transport"); break; } this.rpc = new client_js_1.Client(new client_js_1.RequestManager([this.transport])); this.validator = new schema_utils_js_1.MethodCallValidator(EthereumJSONRPC.openrpcDocument); } /** * Adds a JSONRPC notification handler to handle receiving notifications. * @example * myClient.onNotification((data)=>console.log(data)); */ onNotification(callback) { this.rpc.onNotification(callback); } /** * Adds an optional JSONRPCError handler to handle receiving errors that cannot be resolved to a specific request * @example * myClient.onError((err: JSONRPCError)=>console.log(err.message)); */ onError(callback) { this.rpc.onError(callback); } /** * Sets a default timeout in ms for all requests excluding notifications. * @example * // 20s timeout * myClient.setDefaultTimeout(20000); * // Removes timeout from request * myClient.setDefaultTimeout(undefined); */ setDefaultTimeout(ms) { this.timeout = ms; } /** * Initiates [[EthereumJSONRPC.startBatch]] in order to build a batch call. * * Subsequent calls to [[EthereumJSONRPC.request]] will be added to the batch. * Once [[EthereumJSONRPC.stopBatch]] is called, the promises for the [[EthereumJSONRPC.request]] * will then be resolved. If there is already a batch in progress this method is a noop. * * @example * myClient.startBatch(); * myClient.foo().then(() => console.log("foobar")) * myClient.bar().then(() => console.log("foobarbaz")) * myClient.stopBatch(); */ startBatch() { return this.rpc.startBatch(); } /** * Initiates [[Client.stopBatch]] in order to finalize and send the batch to the underlying transport. * * stopBatch will send the [[EthereumJSONRPC]] calls made since the last [[EthereumJSONRPC.startBatch]] call. For * that reason, [[EthereumJSONRPC.startBatch]] MUST be called before [[EthereumJSONRPC.stopBatch]]. * * @example * myClient.startBatch(); * myClient.foo().then(() => console.log("foobar")) * myClient.bar().then(() => console.log("foobarbaz")) * myClient.stopBatch(); */ stopBatch() { return this.rpc.stopBatch(); } request(methodName, params) { const methodObject = lodash_1.default.find(EthereumJSONRPC.openrpcDocument.methods, ({ name }) => name === methodName); const notification = methodObject.result ? false : true; const openRpcMethodValidationErrors = this.validator.validate(methodName, params); if (openRpcMethodValidationErrors instanceof schema_utils_js_1.MethodNotFoundError || openRpcMethodValidationErrors.length > 0) { return Promise.reject(openRpcMethodValidationErrors); } let rpcParams; if (methodObject.paramStructure && methodObject.paramStructure === "by-name") { rpcParams = lodash_1.default.zipObject(params, lodash_1.default.map(methodObject.params, "name")); } else { rpcParams = params; } if (notification) { return this.rpc.notify({ method: methodName, params: rpcParams }); } return this.rpc.request({ method: methodName, params: rpcParams }, this.timeout); } } exports.EthereumJSONRPC = EthereumJSONRPC; EthereumJSONRPC.openrpcDocument = { "openrpc": "1.0.0", "info": { "version": "1.3.13", "title": "Ethereum JSON-RPC", "description": "This API lets you interact with an EVM-based client via JSON-RPC", "license": { "name": "Apache 2.0", "url": "https://www.apache.org/licenses/LICENSE-2.0.html" } }, "methods": [{ "name": "web3_clientVersion", "description": "Returns the version of the current client", "summary": "current client version", "params": [], "result": { "name": "clientVersion", "description": "client version", "schema": { "title": "clientVersion", "type": "string" } } }, { "name": "web3_sha3", "summary": "Hashes data", "description": "Hashes data using the Keccak-256 algorithm", "params": [{ "name": "data", "description": "data to hash using the Keccak-256 algorithm", "summary": "data to hash", "schema": { "title": "data", "type": "string", "pattern": "^0x[a-fA-F\\d]+$" } }], "result": { "name": "hashedData", "description": "Keccak-256 hash of the given data", "schema": { "title": "keccak", "type": "string", "description": "Hex representation of a Keccak 256 hash", "pattern": "^0x[a-fA-F\\d]{64}$" } }, "examples": [{ "name": "sha3Example", "params": [{ "name": "sha3ParamExample", "value": "0x68656c6c6f20776f726c64" }], "result": { "name": "sha3ResultExample", "value": "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad" } }] }, { "name": "net_listening", "summary": "returns listening status", "description": "Determines if this client is listening for new network connections.", "params": [], "result": { "name": "netListeningResult", "description": "`true` if listening is active or `false` if listening is not active", "schema": { "title": "isNetListening", "type": "boolean" } }, "examples": [{ "name": "netListeningTrueExample", "description": "example of true result for net_listening", "params": [], "result": { "name": "netListeningExampleFalseResult", "value": true } }] }, { "name": "net_peerCount", "summary": "number of peers", "description": "Returns the number of peers currently connected to this client.", "params": [], "result": { "name": "quantity", "description": "number of connected peers.", "schema": { "title": "numConnectedPeers", "description": "Hex representation of number of connected peers", "type": "string" } } }, { "name": "net_version", "summary": "Network identifier associated with network", "description": "Returns the network ID associated with the current network.", "params": [], "result": { "name": "networkId", "description": "Network ID associated with the current network", "schema": { "title": "networkId", "type": "string", "pattern": "^[\\d]+$" } } }, { "name": "eth_blockNumber", "summary": "Returns the number of most recent block.", "params": [], "result": { "name": "blockNumber", "required": true, "schema": { "title": "blockNumberOrTag", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "blockNumberTag", "type": "string", "description": "The optional block height description", "enum": ["earliest", "latest", "pending"] }] } } }, { "name": "eth_call", "summary": "Executes a new message call (locally) immediately without creating a transaction on the block chain.", "params": [{ "required": true, "name": "transaction", "schema": { "title": "transaction", "type": "object", "required": ["gas", "gasPrice", "nonce"], "properties": { "blockHash": { "title": "blockHashOrNull", "description": "The block hash or null when its the pending block", "oneOf": [{ "title": "keccak", "type": "string", "description": "Hex representation of a Keccak 256 hash", "pattern": "^0x[a-fA-F\\d]{64}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "blockNumber": { "title": "blockNumberOrNull", "description": "The block number or null when its the pending block", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "null", "type": "null", "description": "Null" }] }, "from": { "title": "From", "description": "The sender of the transaction", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, "gas": { "title": "transactionGas", "type": "string", "description": "The gas limit provided by the sender in Wei" }, "gasPrice": { "title": "transactionGasPrice", "type": "string", "description": "The gas price willing to be paid by the sender in Wei" }, "hash": { "title": "transactionHash", "type": "string", "description": "Keccak 256 Hash of the RLP encoding of a transaction", "pattern": "^0x[a-fA-F\\d]{64}$" }, "input": { "title": "transactionInput", "type": "string", "description": "The data field sent with the transaction" }, "nonce": { "title": "transactionNonce", "description": "The total number of prior transactions made by the sender", "type": "string", "pattern": "^0x[a-fA-F0-9]+$" }, "to": { "title": "To", "description": "Destination address of the transaction. Null if it was a contract create.", "oneOf": [{ "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "transactionIndex": { "title": "transactionIndex", "description": "The index of the transaction. null when its pending", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] }, "value": { "title": "transactionValue", "description": "Value of Ether being transferred in Wei", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "v": { "title": "transactionSigV", "type": "string", "description": "ECDSA recovery id" }, "r": { "title": "transactionSigR", "type": "string", "description": "ECDSA signature r" }, "s": { "title": "transactionSigS", "type": "string", "description": "ECDSA signature s" } } } }, { "name": "blockNumber", "required": true, "schema": { "title": "blockNumberOrTag", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "blockNumberTag", "type": "string", "description": "The optional block height description", "enum": ["earliest", "latest", "pending"] }] } }], "result": { "name": "returnValue", "description": "The return value of the executed contract", "schema": { "title": "bytes", "type": "string", "description": "Hex representation of a variable length byte array", "pattern": "^0x([a-fA-F0-9]?)+$" } } }, { "name": "eth_chainId", "summary": "Returns the currently configured chain id", "description": "Returns the currently configured chain id, a value used in replay-protected transaction signing as introduced by [EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md).", "params": [], "result": { "name": "chainId", "description": "hex format integer of the current chain id. Defaults are ETC=61, ETH=1, Morden=62.", "schema": { "title": "chainId", "type": "string", "pattern": "^0x[a-fA-F\\d]+$" } } }, { "name": "eth_coinbase", "summary": "Returns the client coinbase address.", "params": [], "result": { "name": "address", "description": "The address owned by the client that is used as default for things like the mining reward", "schema": { "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" } } }, { "name": "eth_estimateGas", "summary": "Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.", "params": [{ "required": true, "name": "transaction", "schema": { "title": "transaction", "type": "object", "required": ["gas", "gasPrice", "nonce"], "properties": { "blockHash": { "title": "blockHashOrNull", "description": "The block hash or null when its the pending block", "oneOf": [{ "title": "keccak", "type": "string", "description": "Hex representation of a Keccak 256 hash", "pattern": "^0x[a-fA-F\\d]{64}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "blockNumber": { "title": "blockNumberOrNull", "description": "The block number or null when its the pending block", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "null", "type": "null", "description": "Null" }] }, "from": { "title": "From", "description": "The sender of the transaction", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, "gas": { "title": "transactionGas", "type": "string", "description": "The gas limit provided by the sender in Wei" }, "gasPrice": { "title": "transactionGasPrice", "type": "string", "description": "The gas price willing to be paid by the sender in Wei" }, "hash": { "title": "transactionHash", "type": "string", "description": "Keccak 256 Hash of the RLP encoding of a transaction", "pattern": "^0x[a-fA-F\\d]{64}$" }, "input": { "title": "transactionInput", "type": "string", "description": "The data field sent with the transaction" }, "nonce": { "title": "transactionNonce", "description": "The total number of prior transactions made by the sender", "type": "string", "pattern": "^0x[a-fA-F0-9]+$" }, "to": { "title": "To", "description": "Destination address of the transaction. Null if it was a contract create.", "oneOf": [{ "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "transactionIndex": { "title": "transactionIndex", "description": "The index of the transaction. null when its pending", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] }, "value": { "title": "transactionValue", "description": "Value of Ether being transferred in Wei", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "v": { "title": "transactionSigV", "type": "string", "description": "ECDSA recovery id" }, "r": { "title": "transactionSigR", "type": "string", "description": "ECDSA signature r" }, "s": { "title": "transactionSigS", "type": "string", "description": "ECDSA signature s" } } } }], "result": { "name": "gasUsed", "description": "The amount of gas used", "schema": { "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" } } }, { "name": "eth_gasPrice", "summary": "Returns the current price per gas in wei", "params": [], "result": { "name": "gasPrice", "required": true, "schema": { "title": "gasPriceResult", "description": "Integer of the current gas price", "type": "string", "pattern": "^0x[a-fA-F0-9]+$" } } }, { "name": "eth_getBalance", "summary": "Returns Ether balance of a given or account or contract", "params": [{ "name": "address", "required": true, "description": "The address of the account or contract", "schema": { "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" } }, { "name": "blockNumber", "description": "A BlockNumber at which to request the balance", "schema": { "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" } }], "result": { "name": "getBalanceResult", "schema": { "title": "integerOrNull", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] } } }, { "name": "eth_getBlockByHash", "summary": "Gets a block for a given hash", "params": [{ "name": "blockHash", "required": true, "schema": { "title": "blockHash", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$", "description": "The hex representation of the Keccak 256 of the RLP encoded block" } }, { "name": "includeTransactions", "description": "If `true` it returns the full transaction objects, if `false` only the hashes of the transactions.", "required": true, "schema": { "title": "isTransactionsIncluded", "type": "boolean" } }], "result": { "name": "getBlockByHashResult", "schema": { "title": "blockOrNull", "oneOf": [{ "title": "Block", "description": "The Block is the collection of relevant pieces of information (known as the block header), together with information corresponding to the comprised transactions, and a set of other block headers that are known to have a parent equal to the present block’s parent’s parent.", "type": "object", "properties": { "number": { "title": "blockNumberOrNull", "description": "The block number or null when its the pending block", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "null", "type": "null", "description": "Null" }] }, "hash": { "title": "blockHashOrNull", "description": "The block hash or null when its the pending block", "oneOf": [{ "title": "keccak", "type": "string", "description": "Hex representation of a Keccak 256 hash", "pattern": "^0x[a-fA-F\\d]{64}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "parentHash": { "title": "blockHash", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$", "description": "The hex representation of the Keccak 256 of the RLP encoded block" }, "nonce": { "title": "nonceOrNull", "description": "Randomly selected number to satisfy the proof-of-work or null when its the pending block", "oneOf": [{ "title": "nonce", "description": "A number only to be used once", "type": "string", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "null", "type": "null", "description": "Null" }] }, "sha3Uncles": { "title": "blockShaUncles", "description": "Keccak hash of the uncles data in the block", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "logsBloom": { "title": "blockLogsBloom", "type": "string", "description": "The bloom filter for the logs of the block or null when its the pending block", "pattern": "^0x[a-fA-F\\d]+$" }, "transactionsRoot": { "title": "blockTransactionsRoot", "description": "The root of the transactions trie of the block.", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "stateRoot": { "title": "blockStateRoot", "description": "The root of the final state trie of the block", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "receiptsRoot": { "title": "blockReceiptsRoot", "description": "The root of the receipts trie of the block", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "miner": { "title": "addressOrNull", "oneOf": [{ "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "difficulty": { "title": "blockDifficulty", "type": "string", "description": "Integer of the difficulty for this block" }, "totalDifficulty": { "title": "blockTotalDifficulty", "description": "Integer of the total difficulty of the chain until this block", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] }, "extraData": { "title": "blockExtraData", "type": "string", "description": "The 'extra data' field of this block" }, "size": { "title": "blockSize", "type": "string", "description": "Integer the size of this block in bytes" }, "gasLimit": { "title": "blockGasLimit", "type": "string", "description": "The maximum gas allowed in this block" }, "gasUsed": { "title": "blockGasUsed", "type": "string", "description": "The total used gas by all transactions in this block" }, "timestamp": { "title": "blockTimeStamp", "type": "string", "description": "The unix timestamp for when the block was collated" }, "transactions": { "title": "transactionsOrHashes", "description": "Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter", "type": "array", "items": { "title": "transactionOrTransactionHash", "oneOf": [{ "title": "transaction", "type": "object", "required": ["gas", "gasPrice", "nonce"], "properties": { "blockHash": { "title": "blockHashOrNull", "description": "The block hash or null when its the pending block", "oneOf": [{ "title": "keccak", "type": "string", "description": "Hex representation of a Keccak 256 hash", "pattern": "^0x[a-fA-F\\d]{64}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "blockNumber": { "title": "blockNumberOrNull", "description": "The block number or null when its the pending block", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "null", "type": "null", "description": "Null" }] }, "from": { "title": "From", "description": "The sender of the transaction", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, "gas": { "title": "transactionGas", "type": "string", "description": "The gas limit provided by the sender in Wei" }, "gasPrice": { "title": "transactionGasPrice", "type": "string", "description": "The gas price willing to be paid by the sender in Wei" }, "hash": { "title": "transactionHash", "type": "string", "description": "Keccak 256 Hash of the RLP encoding of a transaction", "pattern": "^0x[a-fA-F\\d]{64}$" }, "input": { "title": "transactionInput", "type": "string", "description": "The data field sent with the transaction" }, "nonce": { "title": "transactionNonce", "description": "The total number of prior transactions made by the sender", "type": "string", "pattern": "^0x[a-fA-F0-9]+$" }, "to": { "title": "To", "description": "Destination address of the transaction. Null if it was a contract create.", "oneOf": [{ "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "transactionIndex": { "title": "transactionIndex", "description": "The index of the transaction. null when its pending", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] }, "value": { "title": "transactionValue", "description": "Value of Ether being transferred in Wei", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "v": { "title": "transactionSigV", "type": "string", "description": "ECDSA recovery id" }, "r": { "title": "transactionSigR", "type": "string", "description": "ECDSA signature r" }, "s": { "title": "transactionSigS", "type": "string", "description": "ECDSA signature s" } } }, { "title": "transactionHash", "type": "string", "description": "Keccak 256 Hash of the RLP encoding of a transaction", "pattern": "^0x[a-fA-F\\d]{64}$" }] } }, "uncles": { "title": "uncleHashes", "description": "Array of uncle hashes", "type": "array", "items": { "title": "uncleHash", "description": "Block hash of the RLP encoding of an uncle block", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" } } } }, { "title": "null", "type": "null", "description": "Null" }] } } }, { "name": "eth_getBlockByNumber", "summary": "Gets a block for a given number", "params": [{ "name": "blockNumber", "required": true, "schema": { "title": "blockNumberOrTag", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "blockNumberTag", "type": "string", "description": "The optional block height description", "enum": ["earliest", "latest", "pending"] }] } }, { "name": "includeTransactions", "description": "If `true` it returns the full transaction objects, if `false` only the hashes of the transactions.", "required": true, "schema": { "title": "isTransactionsIncluded", "type": "boolean" } }], "result": { "name": "getBlockByNumberResult", "schema": { "title": "blockOrNull", "oneOf": [{ "title": "Block", "description": "The Block is the collection of relevant pieces of information (known as the block header), together with information corresponding to the comprised transactions, and a set of other block headers that are known to have a parent equal to the present block’s parent’s parent.", "type": "object", "properties": { "number": { "title": "blockNumberOrNull", "description": "The block number or null when its the pending block", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "null", "type": "null", "description": "Null" }] }, "hash": { "title": "blockHashOrNull", "description": "The block hash or null when its the pending block", "oneOf": [{ "title": "keccak", "type": "string", "description": "Hex representation of a Keccak 256 hash", "pattern": "^0x[a-fA-F\\d]{64}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "parentHash": { "title": "blockHash", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$", "description": "The hex representation of the Keccak 256 of the RLP encoded block" }, "nonce": { "title": "nonceOrNull", "description": "Randomly selected number to satisfy the proof-of-work or null when its the pending block", "oneOf": [{ "title": "nonce", "description": "A number only to be used once", "type": "string", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "null", "type": "null", "description": "Null" }] }, "sha3Uncles": { "title": "blockShaUncles", "description": "Keccak hash of the uncles data in the block", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "logsBloom": { "title": "blockLogsBloom", "type": "string", "description": "The bloom filter for the logs of the block or null when its the pending block", "pattern": "^0x[a-fA-F\\d]+$" }, "transactionsRoot": { "title": "blockTransactionsRoot", "description": "The root of the transactions trie of the block.", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "stateRoot": { "title": "blockStateRoot", "description": "The root of the final state trie of the block", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "receiptsRoot": { "title": "blockReceiptsRoot", "description": "The root of the receipts trie of the block", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "miner": { "title": "addressOrNull", "oneOf": [{ "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "difficulty": { "title": "blockDifficulty", "type": "string", "description": "Integer of the difficulty for this block" }, "totalDifficulty": { "title": "blockTotalDifficulty", "description": "Integer of the total difficulty of the chain until this block", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] }, "extraData": { "title": "blockExtraData", "type": "string", "description": "The 'extra data' field of this block" }, "size": { "title": "blockSize", "type": "string", "description": "Integer the size of this block in bytes" }, "gasLimit": { "title": "blockGasLimit", "type": "string", "description": "The maximum gas allowed in this block" }, "gasUsed": { "title": "blockGasUsed", "type": "string", "description": "The total used gas by all transactions in this block" }, "timestamp": { "title": "blockTimeStamp", "type": "string", "description": "The unix timestamp for when the block was collated" }, "transactions": { "title": "transactionsOrHashes", "description": "Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter", "type": "array", "items": { "title": "transactionOrTransactionHash", "oneOf": [{ "title": "transaction", "type": "object", "required": ["gas", "gasPrice", "nonce"], "properties": { "blockHash": { "title": "blockHashOrNull", "description": "The block hash or null when its the pending block", "oneOf": [{ "title": "keccak", "type": "string", "description": "Hex representation of a Keccak 256 hash", "pattern": "^0x[a-fA-F\\d]{64}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "blockNumber": { "title": "blockNumberOrNull", "description": "The block number or null when its the pending block", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "null", "type": "null", "description": "Null" }] }, "from": { "title": "From", "description": "The sender of the transaction", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, "gas": { "title": "transactionGas", "type": "string", "description": "The gas limit provided by the sender in Wei" }, "gasPrice": { "title": "transactionGasPrice", "type": "string", "description": "The gas price willing to be paid by the sender in Wei" }, "hash": { "title": "transactionHash", "type": "string", "description": "Keccak 256 Hash of the RLP encoding of a transaction", "pattern": "^0x[a-fA-F\\d]{64}$" }, "input": { "title": "transactionInput", "type": "string", "description": "The data field sent with the transaction" }, "nonce": { "title": "transactionNonce", "description": "The total number of prior transactions made by the sender", "type": "string", "pattern": "^0x[a-fA-F0-9]+$" }, "to": { "title": "To", "description": "Destination address of the transaction. Null if it was a contract create.", "oneOf": [{ "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, { "title": "null", "type": "null", "description": "Null" }] }, "transactionIndex": { "title": "transactionIndex", "description": "The index of the transaction. null when its pending", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] }, "value": { "title": "transactionValue", "description": "Value of Ether being transferred in Wei", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" }, "v": { "title": "transactionSigV", "type": "string", "description": "ECDSA recovery id" }, "r": { "title": "transactionSigR", "type": "string", "description": "ECDSA signature r" }, "s": { "title": "transactionSigS", "type": "string", "description": "ECDSA signature s" } } }, { "title": "transactionHash", "type": "string", "description": "Keccak 256 Hash of the RLP encoding of a transaction", "pattern": "^0x[a-fA-F\\d]{64}$" }] } }, "uncles": { "title": "uncleHashes", "description": "Array of uncle hashes", "type": "array", "items": { "title": "uncleHash", "description": "Block hash of the RLP encoding of an uncle block", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$" } } } }, { "title": "null", "type": "null", "description": "Null" }] } } }, { "name": "eth_getBlockTransactionCountByHash", "summary": "Returns the number of transactions in a block from a block matching the given block hash.", "params": [{ "name": "blockHash", "required": true, "schema": { "title": "blockHash", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$", "description": "The hex representation of the Keccak 256 of the RLP encoded block" } }], "result": { "name": "blockTransactionCountByHash", "description": "The Number of total transactions in the given block", "schema": { "title": "integerOrNull", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] } } }, { "name": "eth_getBlockTransactionCountByNumber", "summary": "Returns the number of transactions in a block from a block matching the given block number.", "params": [{ "name": "blockNumber", "required": true, "schema": { "title": "blockNumberOrTag", "oneOf": [{ "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, { "title": "blockNumberTag", "type": "string", "description": "The optional block height description", "enum": ["earliest", "latest", "pending"] }] } }], "result": { "name": "blockTransactionCountByHash", "description": "The Number of total transactions in the given block", "schema": { "title": "integerOrNull", "oneOf": [{ "title": "integer", "type": "string", "pattern": "^0x[a-fA-F0-9]+$", "description": "Hex representation of the integer" }, { "title": "null", "type": "null", "description": "Null" }] } } }, { "name": "eth_getCode", "summary": "Returns code at a given contract address", "params": [{ "name": "address", "required": true, "description": "The address of the contract", "schema": { "title": "address", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" } }, { "name": "blockNumber", "description": "A BlockNumber of which the code existed", "schema": { "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" } }], "result": { "name": "bytes", "schema": { "title": "bytes", "type": "string", "description": "Hex representation of a variable length byte array", "pattern": "^0x([a-fA-F0-9]?)+$" } } }, { "name": "eth_getFilterChanges", "summary": "Polling method for a filter, which returns an array of logs which occurred since last poll.", "params": [{ "name": "filterId", "required": true, "schema": { "title": "filterId", "type": "string", "description": "An identifier used to reference the filter." } }], "result": { "name": "logResult", "schema": { "title": "logResult", "type": "array", "items": { "title": "log", "type": "object", "description": "An indexed event generated during a transaction", "properties": { "address": { "title": "LogAddress", "description": "Sender of the transaction", "type": "string", "pattern": "^0x[a-fA-F\\d]{40}$" }, "blockHash": { "title": "blockHash", "type": "string", "pattern": "^0x[a-fA-F\\d]{64}$", "description": "The hex representation of the Keccak 256 of the RLP encoded block" }, "blockNumber": { "title": "blockNumber", "type": "string", "description": "The hex representation of the block's height", "pattern": "^0x[a-fA-F0-9]+$" }, "data": { "title": "LogData", "description": "The data/input string sent along with the transaction", "type": "string", "pattern": "^0x([a-fA-F0-9]?)+$" }, "logIndex": { "title": "LogIndex", "description": "The index of the event within its transaction, null when its pending", "type": "string", "pattern": "^0x[a-fA-F0-9]+$" }, "removed": { "title": "logIsRemoved", "description": "Whether or not the log was orphaned off the main chain", "type": "boolean" }, "topics": { "title": "LogTopics", "description": "Topics are order-dependent. Each topic can also be an array of DATA with 'or' options.", "type": "array", "items": { "title": "topic", "description": "3