Proof of Existence

This sample application uses the TBSP instance on Google Cloud Platform to create a hash for a local file, upload the hash to the blockchain, and validate the hash (to check if the file has been altered).

Run the sample

In a terminal session or in your Docker SDK container, execute the sample proof_of_existence.js:

node ng-rt-digitalAsset-sdk-samples/examples/usecases/proof_of_existence.js

(alias: proof)

You should see output similar to this:

[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Reading and processing file test_file1.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Source: /Users/Documents/GitHub/ng-rt-digitalAsset-sdk-samples/examples/usecases/files/test_file1.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Creating hash of test_file1.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - File hash is: 79xaL9QyNpg8Tdn2f2To...
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Posting a transaction to the blockchain with the File hash...
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - File hash is stored in the blockchain with the transaction id : 47b60c5f6f2d3fe658b2d8abf359c8dc843f06ffe5012d3dd34e86d329cdcf30
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Verifying hash of test_file1.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Hash of file test_file1.txt exists in the blockchain
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence -
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence -
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Reading and processing file test_file2.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Source: /Users/Documents/GitHub/ng-rt-digitalAsset-sdk-samples/examples/usecases/files/test_file2.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Creating hash of test_file2.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - File hash is: dBA5zbuYH3ZvUirewwgR...
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Verifying hash of test_file2.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Hash of file test_file2.txt does not exist in the blockchain
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence -
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence -
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Reading and processing file test_file1_copy.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Source: /Users/Documents/GitHub/ng-rt-digitalAsset-sdk-samples/examples/usecases/files/test_file1_copy.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Creating hash of test_file1_copy.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - File hash is: 79xaL9QyNpg8Tdn2f2To...
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Verifying hash of test_file1_copy.txt
[INFO] ng-rt-digitalAsset-sdk.examples.usecases.proof_of_existence - Hash of file test_file1_copy.txt exists in the blockchain

Click here to understand the output of Proof of Existence

Return to Sample Applications