There is nothing special about putting a hash vs any other piece of data into factom. It allows up to 10 KiB per Entry. I would reccomned a signed hash, as others can also submit hashes potentially fooling your application. also, you probably want a nonce in the entry (or an ExtID), because duplicate entries won't be allowed in m2 within the same hour.
We have some documentation here, but it is a bit lacking.
https://github.com/FactomProject/FactomDocs/blob/master/FactoidAPI.mdYou should know that we are very close to putting out a V2 of the API. It will be json based. It should be fairly easy to port over though. that being said, this is how you would do it with the existing tools:
first run factomd and fctwallet
putting entries into factom is a two stage process. first you need to get a commit (a payment for a piece of data) then you submit the reveal (the data itself)
make sure you have entry credits in fctwallet.
factom-cli balances
it should show you the name of the address which has factoids
if not, run
factom-cli generateaddress ec myecaddress
factom-cli newtransaction txname
factom-cli addinput txname myfactoidaddress 0.5
factom-cli addoutput txname myecaddress 0.5
factom-cli addfee txname myfactoidaddress
factom-cli sign txname
factom-cli submit txname
After 10 minutes, when your run
factom-cli balances
it will show that you now have Entry Credits.
Everything in factom needs to go into a chain. lets use this one as an example: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
http://explorer.factom.org/chain/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855curl -i -X POST -H 'Content-Type: application/json' -d '{"ChainID":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "ExtIDs":["657831", "657832"], "Content":"48656C6C6F20466163746F6D21"}' localhost:8089/v1/compose-entry-submit/myecaddress
that returns:
{"EntryCommit":{"CommitEntryMsg":"0001588a2a467dfac23d2299b690813cec4666b11ecb8d2e6b21bbe983c1412b5f5c9405a537d20
13b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29c5d4b9c41a7bd5
77f16cba749f89fd2ab4aca2b2434f758f16414509702ecd37768d47ef8ec36bfbe48e6f43e1277
5961f1594a5303ea3819c21e7d5fe3ebf0c"},"EntryReveal":{"Entry":"00e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855000a000365783
1000365783248656c6c6f20466163746f6d21"}}
we break that apart and send those to factomd with two calls.
curl -i -X POST -H 'Content-Type: application/json' -d '{"CommitEntryMsg":"0001588a2a467dfac23d2299b690813cec4666b11ecb8d2e6b21bbe983c1412b5f5c9405a537d20
13b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29c5d4b9c41a7bd5
77f16cba749f89fd2ab4aca2b2434f758f16414509702ecd37768d47ef8ec36bfbe48e6f43e1277
5961f1594a5303ea3819c21e7d5fe3ebf0c"}' localhost:8088/v1/commit-entry
curl -i -X POST -H 'Content-Type: application/json' -d '{"Entry":"00e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855000a000365783
1000365783248656c6c6f20466163746f6d21"}' localhost:8088/v1/reveal-entry
After 10 minutes it will show up in the chain. you can check by running
factom-cli get allentries e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
To read it programmatically instead of through a helper function, you can make http calls to get json data. you would find the latest block then iterate backwards getting successively earlier blocks. at the same time you would pull out all the entries that were placed into those blocks.
curl -X GET
http://localhost:8088/v1/chain-head/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855which gives:
{"ChainHead":"112b6855ccce87d7891db32ee0a312dcdbb768ec23f043e88b4d5c66b89a31a3"}
then do
curl -X GET
http://localhost:8088/v1/entry-block-by-keymr/112b6855ccce87d7891db32ee0a312dcdbb768ec23f043e88b4d5c66b89a31a3which gives
{"Header":{"BlockSequenceNumber":4,"ChainID":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","PrevKeyMR":"a7833c0dc44f5475f77eed12b5b7853ee81fe6afb1381cbf29f20b1237bb353a","Timestamp":1479786600},"EntryList":[{"EntryHash":"fac23d2299b690813cec4666b11ecb8d2e6b21bbe983c1412b5f5c9405a537d2","Timestamp":1479786960}]}
we can branch downwards and backwards. The call
curl -X GET
http://localhost:8088/v1/entry-by-hash/fac23d2299b690813cec4666b11ecb8d2e6b21bbe983c1412b5f5c9405a537d2asks for the single entry in the latest block in the chain. There can be more than one entry in a block, but this block just has one. the call gives:
{"ChainID":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Content":"48656c6c6f20466163746f6d21","ExtIDs":["657831","657832"]}
next we can do entry-block-by-keymr to get the second from latest entry block
curl -X GET
http://localhost:8088/v1/entry-block-by-keymr/a7833c0dc44f5475f77eed12b5b7853ee81fe6afb1381cbf29f20b1237bb353awhich gives:
{"Header":{"BlockSequenceNumber":3,"ChainID":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","PrevKeyMR":"19a3c3307083a592f76158e97f605e9b3d3638df5892e53b64d0183fd087f844","Timestamp":1478574600},"EntryList":[{"EntryHash":"d66a0c102cb6d8421c015fc905f263b6389c6a0b7e92306eb72a51104b781d53","Timestamp":1478575080}]}
We can keep repeating getting the entries and getting the previous block until 0000000000000000000000000000000000000000000000000000000000000000 is marked as the previous block. this indicates that it is the first block in the chain.
This might have some info:
https://github.com/FactomProject/FactomDocs/tree/master/DeveloperGuideas well as this:
https://github.com/FactomProject/FactomDocs/blob/master/developerSandboxSetup.mdI hope this is enough to help you get started.