Too busy to read the documentation?
You will find here very simple curl and *shell code samples demonstrating a very basic usage of the Woleet API.
To create a timestamped proof of existence for a file, you first need to create the SHA256 hash of it.
Let's do it using a simple shell command using openssl to do the computation:
$ cat <your file> | openssl dgst -sha256 | cut -d " " -f 2
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Now you have the hash of your file, you can create a data anchor that will allow you to retrieve your proof of existence a few hours later:
Let's use a simple curl command to do a POST request:
curl --request POST \
--url https://api.woleet.io/v1/anchor \
--header 'accept: application/json' \
--header 'authorization: Basic <my realm>' \
--header 'content-type: application/json' \
--data '{"name":"My anchor","hash":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
{
"id":"331674c8-0563-45f4-b363-e6cebc0625bb",
"created":1556397050177,
"lastModified":1556397050177,
"name":"My anchor",
"hash":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"status":"WAIT"
}
You anchor is created!
Its identifier is present in the JSON object returned in the body of the response.
Note the its status is WAIT
, meaning that the proof is waiting to be anchored. The Woleet platform batches proof creation requests, so you will have to wait a mean time of 3 hours to get your proof of existence.
You can probe your anchor status at any time with a simple GET request (or if you have a backend server, use our callback mechanism to get informed in realtime):
curl --request GET \
--url https://api.woleet.io/v1/anchor/331674c8-0563-45f4-b363-e6cebc0625bb \
--header 'accept: application/json' \
--header 'authorization: Basic <my realm>'
{
"id":"331674c8-0563-45f4-b363-e6cebc0625bb",
"created":1556397050177,
"lastModified":1556397050177,
"name":"My anchor",
"hash":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"status":"CONFIRMED"
}
When the status is SENT
(sent to the bitcoin blockchain) or CONFIRMED
(confirmed 6 times by the bitcoin blockchain) you can (and should!) retrieve your proof:
curl --request GET \
--url https://api.woleet.io/v1/receipt/331674c8-0563-45f4-b363-e6cebc0625bb \
--header 'accept: application/json'
{
"targetHash":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"merkleRoot":"ec4a21d9b4f4c60e34700012bfe0b3dacd46d928e9ff7cb12bbc1e8dc567093b",
"proof":[{"left":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},
{"right":"164ea6ef8984a1be9a9064e40f58e1e99f82aa9ecff29bd1a07bee74965f7a49"},
{"left":"19d54943a3ae4172fef2856f953d1eb988e7b512c9b9d06c53e225ae94c231c0"},
{"right":"06f5f7540b35461cd1b9366a9e765c9165bd99c6679cb49d2c67bfae851c54cf"},
{"left":"a3ce3262b6c61042fd7097c19b3af3acc72ceb63dcf53ef2017f184ec4740c78"},
{"right":"4a15851b48ffdafe0212c7e489b1859cee3d7a53dde40393711ec957020f7b02"}],
"anchors":[{"sourceId":"096e1f0f2406210db9b1ba0a1d08615ed8e4bebbdf444c541a21a028ed6829eb",
"type":"BTCOpReturn"}],
"type":"ChainpointSHA256v2",
"@context":"https://w3id.org/chainpoint/v2"
}
You get your proof of existence. Keep it along the proven file: you need both to verify the proof.
You are all set!
What about Java, Javascript, Node, Python and PHP code samples?
For other programming languages, you can generate sample code using our actionable API Reference just below.