Skip to content
quan8 edited this page Jan 6, 2022 · 2 revisions

Lachesis API

Opera fully supports the essential parts of web3 API. There are some subtle differences due to the graph structure of the blockchain. The current doc describes only the differences from web3 API.

For support of web3.js, please refer to web3 for details.

Differences from web3.js API

Pending blocks

Retrieval of pending blocks isn't supported, because Lachesis doesn't have this entity.

Block Header fields

  • "nonce" is always 0
  • "mixHash" is always 0
  • "sha3Uncles" is always 0
  • "mixHash" is always 0
  • "miner" field is an undefined address
  • "difficulty" is always 0
  • "extraData" is always empty
  • "gasLimit" is always 0xFFFFFFFFFFFF , i.e. infinite (Lachesis has a different transaction authorization mechanism)
  • "receiptsRoot" is always 0
  • "timestampNano" additional field, returns block's consensus time in UnixNano

Not supported namespaces

  • shh
  • db
  • bzz

DAG API calls

dag_getEventPayload

returns event (including transactions) by hash or short ID

Parameters:

  • String, - full event ID (hex-encoded 32 bytes) or short event ID.
  • Boolean, - If true it returns the full transaction objects, if false only the hashes of the transactions.

Returns:

  • Object - An event object, or null when no event was found:
  • version: QUANTITY - the event version.
  • epoch: QUANTITY - the event epoch number.
  • seq: QUANTITY - the event sequence number.
  • hash: DATA, 32 Bytes - full event ID.
  • frame: QUANTITY - event's frame number.
  • creator: DATA, 20 Bytes - the address of the event creator (validator).
  • prevEpochHash: DATA, 32 Bytes - the hash of the state of previous epoch
  • parents: Array, - array of event IDs
  • gasPowerLeft: QUANTITY - event's not spent gas power.
  • gasPowerUsed: QUANTITY - event's spent gas power.
  • lamport: QUANTITY - event's Lamport index.
  • creationTime: QUANTITY - the UnixNano timestamp of creator's local creation time.
  • medianTime: QUANTITY - the UnixNano timestamp of the secure median time.
  • extraData: DATA - the "extra data" field of this event.
  • transactionsRoot: DATA, 32 Bytes - the root of the transaction trie of the event.
  • transactions: Array - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
Example with short ID

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"dag_getEventPayload","params":["1:3:a2395846", true],"id":1}' localhost:18545

Example with full ID

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"dag_getEventPayload","params":["0x00000001000000039bcda184cc9e2b20386dcee5f39fe3c4f36f7b47c297ff2b", true],"id":1}' localhost:18545

dag_getEvent

returns the event (without transactions) by hash or short ID.

Parameters:

  • String - full event ID (hex-encoded 32 bytes) or short event ID.

Returns:

  • Object - An event object, or null when no event was found:
  • version: QUANTITY - the event version.
  • epoch: QUANTITY - the event epoch number.
  • seq: QUANTITY - the event sequence number.
  • hash: DATA, 32 Bytes - full event ID.
  • seq: QUANTITY - the event sequence number.
  • frame: QUANTITY - event's frame number.
  • creator: QUANTITY, - the ID of the event creator (validator).
  • prevEpochHash: DATA, 32 Bytes - the hash of the state of previous epoch
  • parents: Array, - array of event IDs
  • gasPowerLeft.shortTerm: QUANTITY - event's not spent gas power in short-term gas power window.
  • gasPowerLeft.longTerm: QUANTITY - event's not spent gas power in long-term gas power window.
  • gasPowerUsed: QUANTITY - event's spent gas power.
  • lamport: QUANTITY - event's Lamport index.
  • creationTime: QUANTITY - the UnixNano timestamp of creator's local creation time.
  • medianTime: QUANTITY - the UnixNano timestamp of the secure median time.
  • extraData: DATA - the "extra data" field of this event.
  • transactionsRoot: DATA, 32 Bytes - the hash of transactions of the event.
Example with short ID

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"dag_getEvent","params":["1:3:a2395846"],"id":1}' localhost:18545

Example with full ID

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"dag_getEvent","params":["0x00000001000000039bcda184cc9e2b20386dcee5f39fe3c4f36f7b47c297ff2b"],"id":1}' localhost:18545

dag_getHeads

returns IDs of all the epoch events with no descendants in a given epoch

Parameters:

  • String, - epoch number (HEX-encoded) for a specific epoch (pass “latest” to use latest epoch; pass “pending” to use latest sealed epoch).

Returns:

  • Array - Array of event IDs

Example:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"dag_getHeads","params":["latest"],"id":1}' localhost:18545

FTM API calls

ftm_currentEpoch

returns current epoch number

Returns:

  • String - epoch number (HEX-encoded)

Example:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"ftm_currentEpoch","id":1}' localhost:18545

aBFT API calls

abft_getDowntime

return information about validator downtime.

Parameters:

  • Int - validatorID

Returns:

  • Object - downtime information:
    • downtime: Int
    • missedBlocks: Int

abft_getEpochUptime

return information about validator epoch uptime.

Parameters:

  • Int - validatorID

Returns:

  • Int - validator uptime in current epoch in nanoseconds

abft_getOriginatedFee

return information about total amount of fee from transactions originated by the validator during current epoch.

Parameters:

  • Int - validatorID

Returns:

  • Int - total amount of fee