factomdjs
v0.4.1
Published
JavaScript implementation of the Factomd API v2.0
Downloads
9
Readme
factomdjs
JavaScript implementation of the factomd API v2.
Installation
$ npm install factomdjs --save
Usage
const factomdjs = require('factomdjs');
const factomd = new factomdjs.Factomd()
// By default the library connect to a courtesy node hosted by factom.com.
// Use setFactomNode to connect to a specific Factom Node.
// factomd.setFactomNode('http://localhost:8088/v2');
// Example to retrieve the content of an entry
factomd.entry('ce3df00a20b6aaaf14f8ff0a2c3efa854160245cf17ce9d36a8ff03090a1135e')
.then(res => Buffer.from(res.content, 'hex').toString('utf8'))
.then(console.log);
Table of Contents
- setFactomNode
- setTimeout
- dispatch
- directoryBlock
- directoryBlockHead
- heights
- rawData
- dblockByHeight
- ablockByHeight
- ecblockByHeight
- fblockByHeight
- factoidBlock
- entryCreditBlock
- adminBlock
- entryBlock
- entry
- pendingEntries
- transaction
- ack
- receipt
- pendingTransactions
- chainHead
- entryCreditBalance
- factoidBalance
- entryCreditRate
- properties
- factoidSubmit
- commit_chain
- revealChain
- commitEntry
- revealEntry
- sendRawMessage
setFactomNode
Set the URL of the factom node.
Parameters
url
url of the factom node
setTimeout
Set the timeout of the JSON request to the factom node
Parameters
timeout
Number Set the timeout in milliseconds
dispatch
Utility commands for dispatching JSON commands to the factom server.
Parameters
jdata
Array
directoryBlock
The directory block head is the last known directory block by factom, or in other words, the most recently recorded block.
Parameters
directoryBlockHead
The directory block head is the last known directory block by factom, or in other words, the most recently recorded block.
Parameters
id
Number arbitrary reference id
heights
Returns various heights that allows you to view the state of the blockchain. https://docs.factom.com/api#heights
Parameters
id
Number arbitrary reference id
rawData
Retrieve an entry or transaction in raw format, the data is a hex encoded string. https://docs.factom.com/api#raw-data
Parameters
dblockByHeight
Retrieve a directory block given only its height.
Parameters
ablockByHeight
Retrieve administrative blocks for any given height.
Parameters
ecblockByHeight
Retrieve the entry credit block for any given height. These blocks contain entry credit transaction information.
Parameters
fblockByHeight
Retrieve the factoid block for any given height. These blocks contain factoid arbitrary information.
Parameters
factoidBlock
Retrieve a specified factoid block given its merkle root key.
Parameters
entryCreditBlock
Retrieve a specified entrycredit block given its merkle root key. The numbers are minute markers.
Parameters
adminBlock
Retrieve a specified admin block given its merkle root key.
Parameters
entryBlock
Retrieve a specified entry block given its merkle root key. The entry block contains 0 to many entries
Parameters
entry
Get an Entry from factomd specified by the Entry Hash.
Parameters
pendingEntries
Returns an array of the entries that have been submitted but have not been recoreded into the blockchain.
Parameters
id
Number arbitrary reference id
transaction
Retrieve details of a factoid arbitrary using a transactions hash. Note that information regarding the directory block height, directory block keymr, and transaction block keymr are also included. The “blockheight” parameter in the reponse will always be 0 when using this call, refer to “includedindirectoryblockheight” if you need the height.
Parameters
id
Number arbitrary reference id
ack
Find the status of a transaction, whether it be a factoid, reveal entry, or commit entry.
Parameters
receipt
Retrieve a reciept providing cryptographially verfiable proof that information was recorded in the factom blockchain and that this was subsequently anchored in the bitcoin blockchain.
Parameters
pendingTransactions
Retrieve a reciept providing cryptographially verfiable proof that information was recorded in the factom blockchain and that this was subsequently anchored in the bitcoin blockchain.
Parameters
chainHead
Return the keymr of the head of the chain for a chain ID (the unique hash created when the chain was created).
Parameters
entryCreditBalance
Return its current balance for a specific entry credit address.
Parameters
factoidBalance
This call returns the number of Factoshis (Factoids *10^-8) that are currently available at the address specified.
Parameters
entryCreditRate
Returns the number of Factoshis (Factoids *10^-8) that purchase a single Entry Credit. The minimum factoid fees are also determined by this rate, along with how complex the factoid arbitrary is.
Parameters
id
Number arbitrary reference id
properties
Retrieve current properties of the Factom system, including the software and the API versions.
Parameters
id
Number arbitrary reference id
factoidSubmit
Submit a factoid arbitrary with hex encoded string documented here: https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#factoid-transaction A factoid-submit api call can be composed with factom_walletd.compose-transaction
Parameters
commit_chain
Send a Chain Commit Message to factomd to create a new Chain The commit chain hex encoded string is documented here: https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#chain-commit https://docs.factom.com/api#factoid-submit
Parameters
revealChain
Reveal the First Entry in a Chain to factomd after the Commit to compleate the Chain creation. The reveal chain hex encoded string is documented here: https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry https://docs.factom.com/api#factoid-submit
Parameters
commitEntry
Send an Entry Commit Message to factom to create a new Entry. The entry commit hex encoded string is documented here: https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry-commit https://docs.factom.com/api#reveal-chain
Parameters
revealEntry
Reveal an Entry to factomd after the Commit to compleate the Entry creation. The reveal entry hex encoded string is documented here: https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#entry https://docs.factom.com/api#reveal-entry
Parameters
sendRawMessage
Send a raw hex encoded binary message to the Factom network. This is mostly just for debugging and testing. https://docs.factom.com/api#send-raw-message
Parameters