1 | <?php |
||
5 | class FactomApi extends FactomConnector |
||
6 | { |
||
7 | /** |
||
8 | * Every directory block has a KeyMR (Key Merkle Root), which can be used to retrieve it. |
||
9 | * |
||
10 | * @url https://docs.factom.com/api#directory-block |
||
11 | * |
||
12 | * @return json { object header, object entryblocklist } |
||
13 | */ |
||
14 | public function directoryBlock(string $keymr) |
||
23 | |||
24 | /** |
||
25 | * The directory block head is the last known directory block by factom, or in other words, the |
||
26 | * most recently recorded block. |
||
27 | * |
||
28 | * @url https://docs.factom.com/api#directory-block-head |
||
29 | * |
||
30 | * @return json { string keymr } |
||
31 | */ |
||
32 | public function directoryBlockHead() |
||
39 | |||
40 | /** |
||
41 | * Returns various heights that allows you to view the state of the blockchain. |
||
42 | * |
||
43 | * @url https://docs.factom.com/api#heights |
||
44 | * |
||
45 | * @return json { ... } |
||
46 | */ |
||
47 | public function heights() |
||
54 | |||
55 | /** |
||
56 | * Retrieve an entry or transaction in raw format, the data is a hex encoded string. |
||
57 | * |
||
58 | * @url https://docs.factom.com/api#raw-data |
||
59 | * |
||
60 | * @return json { string data } |
||
61 | */ |
||
62 | public function rawData(string $hash) |
||
71 | |||
72 | /** |
||
73 | * Retrieve a directory block given only its height. |
||
74 | * |
||
75 | * @url https://docs.factom.com/api#dblock-by-height |
||
76 | * |
||
77 | * @return json { object dblock, string rawdata } |
||
78 | */ |
||
79 | public function dblockByHeight(int $height) |
||
88 | |||
89 | /** |
||
90 | * Retrieve administrative blocks for any given height. |
||
91 | * |
||
92 | * @url https://docs.factom.com/api#ablock-by-height |
||
93 | * |
||
94 | * @return json { object ablock, string rawdata } |
||
95 | */ |
||
96 | public function ablockByHeight(int $height) |
||
105 | |||
106 | /** |
||
107 | * Retrieve the entry credit block for any given height. |
||
108 | * |
||
109 | * @url https://docs.factom.com/api#ecblock-by-height |
||
110 | * |
||
111 | * @return json { object ecblock, string rawdata } |
||
112 | */ |
||
113 | public function ecblockByHeight(int $height) |
||
122 | |||
123 | /** |
||
124 | * Retrieve the factoid block for any given height. |
||
125 | * |
||
126 | * @url https://docs.factom.com/api#fblock-by-height |
||
127 | * |
||
128 | * @return json { object fblock, string rawdata } |
||
129 | */ |
||
130 | public function fblockByHeight(int $height) |
||
139 | |||
140 | /** |
||
141 | * Retrieve a specified factoid block given its merkle root key. |
||
142 | * |
||
143 | * @url https://docs.factom.com/api#factoid-block |
||
144 | * |
||
145 | * @return json { object fblock, string rawdata } |
||
146 | */ |
||
147 | public function factoidBlock(string $keymr) |
||
156 | |||
157 | /** |
||
158 | * Retrieve a specified entrycredit block given its merkle root key. |
||
159 | * |
||
160 | * @url https://docs.factom.com/api#entrycredit-block |
||
161 | * |
||
162 | * @return json { object ecblock, string rawdata } |
||
163 | */ |
||
164 | public function entrycreditBlock(string $keymr) |
||
173 | |||
174 | /** |
||
175 | * Retrieve a specified admin block given its merkle root key. |
||
176 | * |
||
177 | * @url https://docs.factom.com/api#admin-block |
||
178 | * |
||
179 | * @return json { object ablock, string rawdata } |
||
180 | */ |
||
181 | public function adminBlock(string $keymr) |
||
190 | |||
191 | /** |
||
192 | * Retrieve a specified entry block given its merkle root key. |
||
193 | * |
||
194 | * @url https://docs.factom.com/api#entry-block |
||
195 | * |
||
196 | * @return json { object header, object entrylist } |
||
197 | */ |
||
198 | public function entryBlock(string $keymr) |
||
207 | |||
208 | /** |
||
209 | * Get an Entry from factomd specified by the Entry Hash. |
||
210 | * |
||
211 | * @url https://docs.factom.com/api#entry |
||
212 | * |
||
213 | * @return json { string chainid, string content, array extids } |
||
214 | */ |
||
215 | public function entry(string $hash) |
||
224 | |||
225 | /** |
||
226 | * Returns an array of the entries that have been submitted but have not been recoreded into the blockchain. |
||
227 | * |
||
228 | * @url https://docs.factom.com/api#pending-entries |
||
229 | * |
||
230 | * @return json { array ... } |
||
231 | */ |
||
232 | public function pendingEntries() |
||
239 | |||
240 | /** |
||
241 | * Retrieve details of a factoid transaction using a transactions hash. |
||
242 | * |
||
243 | * @url https://docs.factom.com/api#transaction |
||
244 | * |
||
245 | * @return json { object ... } |
||
246 | */ |
||
247 | public function transaction(string $hash) |
||
256 | |||
257 | /** |
||
258 | * This api call is used to find the status of a transaction, whether it be a factoid, reveal entry, or commit entry. |
||
259 | * |
||
260 | * @url https://docs.factom.com/api#ack |
||
261 | * |
||
262 | * @return json { object ... } |
||
263 | */ |
||
264 | public function ack(string $hash, string $chainid, string $fulltransaction = null) |
||
275 | |||
276 | /** |
||
277 | * Factoid Acknowledgements will give the current status of a transaction. |
||
278 | * |
||
279 | * @status Depricated - please refer to ack. |
||
280 | * |
||
281 | * @url https://docs.factom.com/api#factoid-ack |
||
282 | * |
||
283 | * @return json { object ... } |
||
284 | */ |
||
285 | public function factoidAck(string $txid) |
||
294 | |||
295 | /** |
||
296 | * Entry Acknowledgements will give the current status of a transaction. |
||
297 | * |
||
298 | * @status Depricated - please refer to ack. |
||
299 | * |
||
300 | * @url https://docs.factom.com/api#factoid-ack |
||
301 | * |
||
302 | * @return json { object ... } |
||
303 | */ |
||
304 | public function entryAck(string $txid) |
||
313 | |||
314 | /** |
||
315 | * Retrieve a reciept providing cryptographially verfiable proof that information was |
||
316 | * recorded in the factom blockchain and that this was subsequently anchored in the |
||
317 | * bitcoin blockchain. |
||
318 | * |
||
319 | * @url https://docs.factom.com/api#receipt |
||
320 | * |
||
321 | * @return json { object ... } |
||
322 | */ |
||
323 | public function receipt(string $hash) |
||
332 | |||
333 | /** |
||
334 | * Returns an array of factoid transactions that have not yet been recorded in the blockchain, |
||
335 | * but are known to the system. |
||
336 | * |
||
337 | * @url https://docs.factom.com/api#pending-transactions |
||
338 | * |
||
339 | * @return json { string TransactionID, string Status } |
||
340 | */ |
||
341 | public function pendingTransactions(string $address) |
||
350 | |||
351 | /** |
||
352 | * Return the keymr of the head of the chain for a chain ID |
||
353 | * (the unique hash created when the chain was created). |
||
354 | * |
||
355 | * @url https://docs.factom.com/api#chain-head |
||
356 | * |
||
357 | * @return json { string ChainHead } |
||
358 | */ |
||
359 | public function chainHead(string $chainid) |
||
368 | |||
369 | /** |
||
370 | * Return its current balance for a specific entry credit address. |
||
371 | * |
||
372 | * @url https://docs.factom.com/api#entry-credit-balance |
||
373 | * |
||
374 | * @return json { int balance } |
||
375 | */ |
||
376 | public function entryCreditBalance(string $address) |
||
385 | |||
386 | /** |
||
387 | * This call returns the number of Factoshis (Factoids *10^-8) that are currently |
||
388 | * available at the address specified. |
||
389 | * |
||
390 | * @url https://docs.factom.com/api#factoid-balance |
||
391 | * |
||
392 | * @return json { int balance } |
||
393 | */ |
||
394 | public function factoidBalance(string $address) |
||
403 | |||
404 | /** |
||
405 | * Returns the number of Factoshis (Factoids *10^-8) that purchase a single Entry Credit. |
||
406 | * |
||
407 | * @url https://docs.factom.com/api#entry-credit-rate |
||
408 | * |
||
409 | * @return json { int rate } |
||
410 | */ |
||
411 | public function entryCreditRate() |
||
418 | |||
419 | /** |
||
420 | * Retrieve current properties of the Factom system, including the software and the API versions. |
||
421 | * |
||
422 | * @url https://docs.factom.com/api#properties |
||
423 | * |
||
424 | * @return json { string factomdversion, string factomdapiversion } |
||
425 | */ |
||
426 | public function properties() |
||
433 | |||
434 | /** |
||
435 | * Submit a factoid transaction. |
||
436 | * |
||
437 | * @url https://docs.factom.com/api#factoid-submit |
||
438 | * |
||
439 | * @return json { string message, string txid } |
||
440 | */ |
||
441 | public function factoidSubmit(string $transaction) |
||
450 | |||
451 | /** |
||
452 | * Send a Chain Commit Message to factomd to create a new Chain. |
||
453 | * |
||
454 | * @url https://docs.factom.com/api#commit-chain |
||
455 | * |
||
456 | * @return json { string message, string txid, string entryhash, string chainid } |
||
457 | */ |
||
458 | public function commitChain(string $message) |
||
467 | |||
468 | /** |
||
469 | * Reveal the First Entry in a Chain to factomd after the Commit to compleate the Chain creation. |
||
470 | * |
||
471 | * @url https://docs.factom.com/api#reveal-chain |
||
472 | * |
||
473 | * @return json { string message, string txid, string entryhash, string chainid } |
||
474 | */ |
||
475 | public function revealChain(string $entry) |
||
484 | |||
485 | /** |
||
486 | * Send an Entry Commit Message to factom to create a new Entry. |
||
487 | * |
||
488 | * @url https://docs.factom.com/api#commit-entry |
||
489 | * |
||
490 | * @return json { string message, string txid, string entryhash } |
||
491 | */ |
||
492 | public function commitEntry(string $message) |
||
501 | |||
502 | /** |
||
503 | * Reveal an Entry to factomd after the Commit to compleate the Entry creation. |
||
504 | * |
||
505 | * @url https://docs.factom.com/api#reveal-entry |
||
506 | * |
||
507 | * @return json { string message, string txid, string entryhash, string chainid } |
||
508 | */ |
||
509 | public function revealEntry(string $entry) |
||
518 | |||
519 | /** |
||
520 | * Send a raw hex encoded binary message to the Factom network. |
||
521 | * |
||
522 | * @url https://docs.factom.com/api#send-raw-message |
||
523 | * |
||
524 | * @return json { string message } |
||
525 | */ |
||
526 | public function sendRawMessage(string $message) |
||
535 | } |
||
536 |