Javascript wrapper for dcrtime
If you want to use this library in a Nodejs environment make sure you are using Node v17.5+ because of fetch.
yarn add dcrtimejs
npm install --save dcrtimejs
Properties
Name | Type | Description |
---|---|---|
digests | array |
array of objects containing the SHA256, result, servertimestamp and chaininformation if applicable |
id | String |
unique identifier |
Properties
Name | Type |
---|---|
id | String |
Properties
Name | Type |
---|---|
versions | Array.<Number> |
routeprefixes | Array.<String> |
Properties
Name | Type | Description |
---|---|---|
chaintimestamp | Number |
chain timestamp if the tx block has more than 6 confirmations |
transaction | String |
id of the latest successfully broadcasted tx |
blockhash | String |
block hash |
blockheight | Number |
block height |
Properties
Name | Type | Description |
---|---|---|
digests | array |
array of objects containing the SHA256, result, servertimestamp and chaininformation if applicable |
Sets the dcrtime server that will be used. Default is mainnet. If network is "testnet", it will be set to testnet. You can also send a custom URL if you want to use your own server
Param | Type |
---|---|
network | string |
getVersions returns the versions available and its route prefixes
Returns: Promise.<VersionsResponse>
- A promise that returns VersionsResponse if resolved
getLastAnchor returns the last successful anchor info request
Returns: Promise.<LastAnchorResponse>
- A promise that returns LastAnchorResponse if resolved
getLastAnchor returns the last n digests submitted
Returns: Promise.<GetLastDigestsResponse>
- A promise that returns GetLastDigestsResponse if resolved
getStatus is used to ask the server if everything is running properly.
Returns: Promise.<StatusResponse>
- A promise that returns StatusResponse if resolved
Param | Type | Description |
---|---|---|
id [optional] | string |
Identifier that can be used if a unique identifier is required. A 200 Status and the unique identifier sent will be returned. |
Timestamps an array of SHA256 hashs using dcrtime.
Param | Type | Description |
---|---|---|
digests | Array[string] |
Array of SHA256 hashs |
id [optional] | string |
Identifier that can be used if a unique identifier is required |
Returns: Promise.<DcrtimeResponse>
- The data from dcrtime.
Timestamps an array of base 64 encoded strings using dcrtime.
Param | Type | Description |
---|---|---|
base64s | Array[string] |
Array of base64 encoded strings |
id [optional] | string |
Identifier that can be used if a unique identifier is required |
Returns: Promise.<DcrtimeResponse>
- The data from dcrtime.
The 'result' key in the returned object means:
Result | Description |
---|---|
0 | Invalid |
1 | The HASH has been sent to the dcrtime server to be anchored |
2 | Hash was already in the server |
Verifies if an array of SHA256 hashs is anchored to the blockchain.
Param | Type | Description |
---|---|---|
digests | Array[string] |
Array of SHA256 hashs |
id [optional] | string |
Identifier that can be used if a unique identifier is required |
Returns: Promise.<DcrtimeResponse>
- The data from dcrtime.
Verifies if an array of base 64 encoded strings is anchored to the blockchain.
Param | Type | Description |
---|---|---|
base64s | Array[string] |
Array of base64 encoded strings |
id [optional] | string |
Identifier that can be used if a unique identifier is required |
Returns: Promise.<DcrtimeResponse>
- The data from dcrtime.
The 'result' key in the returned object means:
Result | Description |
---|---|
0 | Invalid |
1 | Digest was found in the server and verified successfully |
3 | Digest was NOT found in the server and is not anchored |
Calculates the SHA256 hash of a 64bit encoded string
Param | Type | Description |
---|---|---|
base64 | string |
base64 encoded string |
Returns: string
- The SHA256 hash.
import dcrtime from "dcrtimejs";
dcrtime.setNetwork("testnet");
dcrtime.timestamp(["9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"], "dcrtimejs");
dcrtime.timestampFromBase64(["dGVzdA=="], "dcrtimejs");
dcrtime.verify(["9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08"], "dcrtimejs");
dcrtime.verifyFromBase64(["dGVzdA=="], "dcrtimejs");