Testnet launching soon!Join the Community

Reference

JSON-RPC API Reference

Firechain's JSON-RPC API is a standard interface for interacting with Firechain nodes. It is a stateless, light-weight RPC protocol that uses JSON as a data format. It is designed to be simple and easy to implement.

Firechain's JSON-RPC API conforms to the JSON-RPC 2.0 Specification.

Errors

The specification defines several error codes that may be returned by the API. The following table lists the error codes that may be returned by the API, along with their meaning.

CodeMessageDescription
-32001Server PanicThe JSON-RPC server is unable to handle the request.
-32002Callback FailedThe callback was not able to be completed as expected.
-32003 to -32099Server ErrorReserved for implementation-specific internal errors.
-32000Server StoppedThe JSON-RPC server has been stopped.
-32600Invalid RequestThe JSON-RPC request object is invalid.
-32601Method not foundThe JSON-RPC method does not exist or is unavailable.
-32602Invalid paramsInvalid JSON-RPC method parameter(s).
-32603Internal errorInternal JSON-RPC error.
-32700Parse errorAn error occurred while parsing the request.
-34001Decryption ErrorUnable to decrypt content.
-35001Balance ErrorInsufficient balance to complete transfer.
-35002Heat Limit ErrorRequest would exceed account's heat capacity.
-35004Method ErrorInvalid contract method parameter(s).
-35005PoW Limit ErrorToo many outstanding PoW requests to create more.
-35006Code Not FoundUnable to find requested ABI method.
-35007Invalid LatencyThe specified response latency is not valid.
-35008Entity Not FoundNo entity was found at the specified address.
-35009ReservedReserved
-35010Invalid Heat MultiplierThe specified heat multiplier is not valid.
-35011PoW UnavailableThe network is unable to accept PoW requests.
-35012Max Request HeatThe request would exceed the maximum heat capacity.
-36001Invalid ProducerThe specified block producer address is not valid.
-36002Invalid hashThe specified hash is not valid.
-36003Invalid signatureThe specified signature is not valid.
-36004Invalid PoW NonceThe specified PoW nonce is not valid.
-36005Invalid UpstreamThe specified hash does not match the previous block.
-36006Invalid BlockThe specified block is not yet available.

Models

The following models are widely used throughout the Firechain JSON-RPC API.

Response

The specification defines a standard response object that is always returned by the API. The response object contains the following fields:

FieldTypeDescription
jsonrpcStringA String specifying the version of the JSON-RPC protocol. Must be exactly "2.0".
idString or NumberThe request id. This can be of any type. It is used to match the request with the response.
resultAnyThe result of the request. This can be of any type.
errorObjectThe error object in case there was an error.

Error

FieldTypeDescription
codeNumberA Number that indicates the error type that occurred. This MUST be an integer.
messageStringA String providing a short description of the error. The message SHOULD be limited to a concise single sentence.
dataAnyA Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).

Account

FieldTypeDescription
addressStringThe account's address.
heightNumberThe number of entries in the account's transaction history.
balancesMap(tokenId: address, balance: Balance)The account's balances.

Balance

FieldTypeDescription
tokenTokenThe token associated with the balance.
amountNumberThe amount of the balance.
activityNumberThe number of transactions that have been made with the token.

Token

FieldTypeDescription
idStringThe token's ID.
nameStringThe token's name.
symbolStringThe token's symbol.
decimalsNumberThe number of decimal places the token supports.
totalSupplyNumberThe total supply of the token.
maxSupplyNumberThe maximum supply of the token.
mintableBooleanWhether the token is mintable.
burnableBooleanWhether the token is burnable.
transferableBooleanWhether the token is transferable.
creatorStringThe token's creator.

Transaction

FieldTypeDescription
hashStringThe transaction's hash.
typeTxTypeThe transaction's type.
heightNumberThe sending account's height (nonce).
hashStringA hash of the transaction object.
previousHashStringThe hash of previous transaction. A hash of all zeros is used for the account's first transaction.
producerStringValidator's address. This is typically the account address for users, and always a consensus group delegate for on-chain entities.
senderStringThe address of the account from which the transaction was sent.
receiverStringThe address of the account to which the transaction is directed.
tokenIdStringThe ID of the token to transfer, if any.
amountStringThe amount of tokens to transfer, if any.
feeStringFee paid to the validator, if any. Not used at this time.
dataStringUnstructured data, typically used for deploying and interacting with entities.
signatureStringSignature for the transaction object.
logsString[]A list of the hashes of any VM logs generated during execution.
downstreamsTransaction[]A list of downstream requests generated as part of the current execution.
upstreamTransactionThe upstream request that led to the current execution, if applicable.
heatStringThe net heat generated by the transaction, which excludes any amount offset through PoW.
rawHeatStringThe gross heat generated by the transaction, including any offsets from PoW solutions.
confirmationsStringNumber of global confirmations for the transaction.
sealedAtint64The timestamp of the first global confirmation.
sealedInStringThe hash of global block that sealed the transaction.
sealedByStringThe address of the signer of the global block that sealed the transaction.

PoW Fields

If the sender of a transaction used a PoW solution to offset any portion of the transaction's heat, the following fields will be appended:

FieldTypeDescription
difficultyStringDifficulty of the submitted PoW solution, if applicable.
solutionStringThe nonce of an accepted PoW solution, if applicable.

Enums and Constants

TxType

IDTypeDescription
1RequestDeploy new code.
2RequestTransfer token.
3RequestMint token.
4ResponseReply to call.
5ResponseReply with failure/rejection
6RequestCode-initiated refund.
7ResponseInitializer (genesis).

JSON-RPC Methods

The following methods are available in Firechain's JSON-RPC API:

MethodDescription
get_heightReturns the current height of the global state chain.
get_blockReturns the global state entry matching the given hash.
get_block_by_heightReturns the global state entry for the given block height.
get_messageReturns the message for the given message ID.
get_message_receiptReturns the message receipt for the given message ID.
get_message_countReturns the number of messages sent from the given address.
get_balanceReturns the given address's balance of the given token.
get_codehashReturns the codehash of the given address.
get_heat_capacityReturns the heat capacity of the given address.
get_storage_atReturns the storage value at the given position for the given address.
get_peer_countReturns the number of peers connected to the RPC node.
get_versionReturns the version details of the software being run by the RPC node.
get_statusReturns the status of the Firechain node.
get_eventsReturns the events matching the given filter. Can be used to fetch events by block, message, or address.
get_message_eventsReturns the events broadcast during a given message.
get_block_eventsReturns events broadcast during a given global state entry.
send_messageSends a message to the network.
send_raw_messageSends a raw message to the network.
simulateSimulates a message call from the current RPC node. Does not create a message on the network.
estimate_heatAnalyze a message call, which won't be added to the blockchain and returns the amount of heat it should generate, which can be used for estimating the used gas.
get_workReturns a proof-of-work challenge that can be solved by a given account to temporarily unlock more heat tolerance.
submit_workSubmits a proof-of-work solution.

get_height

Returns the current height of the global state chain.

Parameters

None

Returns

Number - The current height of the global state chain.

get_block

Returns the global state entry matching the given block hash.

Parameters

FieldTypeDescription
block_hashStringThe block hash.

Returns

FieldTypeDescription
blockObjectThe global state entry.
block.hashStringThe block hash.
block.numberNumberThe block number.
block.parent_hashStringThe parent block hash.
block.timestampNumberThe block timestamp.
block.heatNumberThe block's total generated heat.
block.messagesArray<Message>The block messages.

get_block_by_height

Returns the global state entry for the given block height.

Parameters

FieldTypeDescription
heightNumberThe block height.

Returns

FieldTypeDescription
blockObjectThe global state entry.
block.hashStringThe block hash.
block.numberNumberThe block number.
block.parent_hashStringThe parent block hash.
block.timestampNumberThe block timestamp.
block.heatNumberThe block's total generated heat.
block.messagesArray<Message>The block messages.

get_message

Returns the message for the given message ID.

Parameters

FieldTypeDescription
message_idStringThe message ID.

Returns

FieldTypeDescription
messageMessageThe message.
message.idStringThe message ID, which is a hash of its contents.
message.timestampNumberThe timestamp in the message's header.
message.versionNumberThe protocol version the message targets.
message.senderStringThe message sender.
message.receiverStringThe message recipient.
message.linksArray<String>The IDs of any referenced messages.
message.bodyHashStringThe hash of the message body.
message.signatureStringThe signature provided by the sender.
message.bodyObjectThe message body.

get_message_receipt

Returns the message receipt for the given message ID.

Parameters

FieldTypeDescription
message_idStringThe message ID.

Returns

FieldTypeDescription
receiptObjectThe message receipt.
receipt.idStringThe message ID, which is a hash of its contents.
receipt.timestampNumberThe timestamp in the message's header.
receipt.heatNumberThe heat generated by the message.
receipt.heat_limitNumberThe heat limit of the message.
receipt.state_rootStringThe account's state root after the message was executed.
receipt.messageMessageThe message.
receipt.eventsArray<Event>The events generated by the message.
receipt.events[].idStringThe event ID.
receipt.events[].nameStringThe event name.
receipt.events[].dataStringThe event data.
receipt.events[].topicsArray<String>The event's indexed topics.

get_message_count

Returns the number of messages sent from the given address.

Parameters

FieldTypeDescription
addressStringThe address.

Returns

Number - The number of messages sent from the given address.

get_balance

Returns the given address's balance of the given token.

Parameters

FieldTypeDescription
addressStringThe address.
tokenString?The token to query. Defaults to the native token.

Returns

Number - The given address's balance of the given token.

get_codehash

Returns the hash of the code stored at the given address, not the code itself. Can be used to verify the currently deployed code matches a known or trusted version, for example.

Parameters

FieldTypeDescription
addressStringThe address.

Returns

String - The hash of the code stored at the given address.

get_heat_capacity

Returns the heat capacity of the given address.

Parameters

FieldTypeDescription
addressStringThe address.

Returns

Number - The heat capacity of the given address.

get_storage_at

Returns the storage value at the given position for the given address. Can be used to retrieve the actual deployed code, or just individual storage values. The value, if reachable, is returned as a hex string.

Parameters

FieldTypeDescription
addressStringThe address.
positionStringThe storage position.

Returns

String - The storage value at the given position for the given address.

get_peer_count

Returns the number of peers connected to the RPC node.

Parameters

None

Returns

Number - The number of peers connected to the RPC node.

get_version

Returns the version details of the software being run by the RPC node.

Parameters

None

Returns

FieldTypeDescription
idStringThe RPC node's implementation identifier.
buildStringThe build of the RPC node software. Usually a git commit hash.
networkStringThe ID of the network supported by the node.
protocolStringThe protocol version supported by the node.

get_status

Returns the status of the Firechain node.

Parameters

None

Returns

FieldTypeDescription
idStringThe RPC node's implementation identifier.
buildStringThe build of the RPC node software. Usually a git commit hash.
networkStringThe ID of the network supported by the node.
protocolStringThe protocol version supported by the node.
heightNumberThe current height of the global state chain.
uptimeNumberThe number of milliseconds the node has been connected to at least 1 peer.
peersNumberThe number of peers connected to the RPC node.
syncingBooleanWhether the node is currently syncing.
operatorStringThe address of the operator of the node.

get_events

Returns the broadcasted events matching the given filter.

Parameters

FieldTypeDescription
filterObjectThe filter.
filter.from_blockNumber?The block height to start searching from. Defaults to the current height.
filter.to_blockNumber?The block height to stop searching at. Defaults to the current height.
filter.addressString?The address to filter for.
filter.topicsArray<String>?The topics to filter for.

Returns

Array<Event> - The broadcasted events matching the filter.

get_message_events

Returns the events broadcasted by the given message.

Parameters

FieldTypeDescription
message_idStringThe message ID.

Returns

Array<Event> - The events broadcasted by the given message.

get_block_events

Returns the events broadcasted in the given global state entry.

Parameters

FieldTypeDescription
block_hashStringThe block hash.

Returns

Array<Event> - The events broadcasted in the given global state entry.

send_message

Sends a message to the Firechain network.

Parameters

FieldTypeDescription
messageMessageThe message.
message.idStringThe message ID, which is a hash of its contents.
message.timestampNumberThe timestamp in the message's header.
message.versionNumberThe protocol version the message targets.
message.senderStringThe message sender.
message.receiverStringThe message recipient.
message.linksArray<String>The IDs of any referenced messages.
message.bodyHashStringThe hash of the message body.
message.signatureStringThe signature provided by the sender.
message.bodyObjectThe message body.

Returns

String - The message ID of the sent message.

send_raw_message

Sends a raw message to the Firechain network.

Parameters

FieldTypeDescription
raw_messageStringThe raw message.

Returns

String - The message ID of the sent message.

simulate

Simulates the execution of a message.

Parameters

FieldTypeDescription
messageMessageThe message.
message.idStringThe message ID, which is a hash of its contents.
message.timestampNumberThe timestamp in the message's header.
message.versionNumberThe protocol version the message targets.
message.senderStringThe message sender.
message.receiverStringThe message recipient.
message.linksArray<String>The IDs of any referenced messages.
message.bodyHashStringThe hash of the message body.
message.signatureStringThe signature provided by the sender.
message.bodyObjectThe message body.

Returns

Object - The simulation result.

estimate_heat

Estimates the amount of heat a message will generate.

Parameters

FieldTypeDescription
messageMessageThe message.
message.idStringThe message ID, which is a hash of its contents.
message.timestampNumberThe timestamp in the message's header.
message.versionNumberThe protocol version the message targets.
message.senderStringThe message sender.
message.receiverStringThe message recipient.
message.linksArray<String>The IDs of any referenced messages.
message.bodyHashStringThe hash of the message body.
message.signatureStringThe signature provided by the sender.
message.bodyObjectThe message body.

Returns

Number - The estimated heat.

get_work

Returns a proof-of-work challenge for the given address.

Parameters

FieldTypeDescription
addressStringThe address.

Returns

FieldTypeDescription
idStringThe challenge ID.
challengeStringThe challenge.
difficultyNumberThe difficulty.
deadlineNumberThe deadline to submit a solution for this challenge.

submit_work

Submits a proof-of-work solution for the given address. Must be submitted by the requester and before the deadline specified in the challenge.

Parameters

FieldTypeDescription
addressStringThe address.
challenge_idStringThe challenge ID.
solutionStringThe solution.

Returns

FieldTypeDescription
successBooleanWhether the solution was accepted.
messageString?The reason for the solution being rejected, if any.
capacityNumber?The heat capacity unlocked by the solution, if any.
expirationNumber?The expiration of the unlocked heat capacity, if applicable.
valueNumber?The number of tokens paid out for the solution, if applicable.
Previous
AVM Instructions