Skip to main content

Webhook Integrity Verification

You can verify webhook integrity by setting a hash key. The webhook hash key can be set to any value, and we recommend using a key of at least 32 bytes.


Setting the hash key​

1. In the console​

When registering a webhook, select Enable for integrity verification. You can set it by entering the hash key value to use.


2. Through the API​

Register a webhook by calling the Create Webhook API. You can set it by entering any hashKey.


Changing the hash key​

1. In the console​

Click the More button on the webhook page. You can change the hash key by clicking the Edit button.


2. Through the API​

Update the webhook information by calling the Update Webhook API. You can change it by entering a hashKey.


Sample code​

1. Deposit​

The webhook is delivered with webhookTargetDataHash added. Only the webhook's data is subject to hashing.

[
{
"webhookIdx": 172,
"webhookTargetIdx": 347051,
"webhookTargetDataScheme": "TRANSACTION_1",
"webhookTargetDataHash": "OKJ5pUHVa24qBW/JdOMKMZ/KYJJXcnYpiUJj+XE0kMQ=", // <-- hash value
"data": {
"memo": null,
"txid": "0xb465105b5ab17684ed31b618fcb03755f9e2bea0ac37c7b988937d9c4f4b727d",
"type": "DEPOSIT",
"uuid": "a9cf3657-8c81-45bc-bbef-0b4facb15205",
"nonce": 45699,
"amount": "0.10000000000000000000",
"status": "FINALIZED",
"symbol": "KAIA",
"usedFee": "0.00077500000000000000",
"toAddress": "0x00732A92d2bf0d54057e6b28be5bcFb409df8E72",
"failedDate": null,
"blockHeight": "122645065",
"createdDate": "2023-05-16T07:30:06.807Z",
"fromAddress": "0x55Bc4ba7A86A00C8A1A09C59DcC32eA2E7FAbCd4",
"outputIndex": 0,
"toAddresses": [
"0x00732A92d2bf0d54057e6b28be5bcFb409df8E72"
],
"modifiedDate": "2023-05-16T07:30:15.000Z",
"finalizedDate": "2023-05-16T07:30:16.000Z",
"fromAddresses": [
"0x55Bc4ba7A86A00C8A1A09C59DcC32eA2E7FAbCd4"
],
"contractAddress": null,
"feePayerAddress": "0x73b14def9a8b01525cb4eff356e01ce611d356aa",
"unfinalizedDate": "2023-05-16T07:30:07.000Z",
"useFeeDelegation": true,
"transactionCurrency": {
"krw": "226.99282922",
"usd": "0.16965089"
}
}
}
]


2. Hashing code​

This is the code Octet uses for hashing. It is the same as the HMAC code used in payload encryption.

function hash(data: Record<string, any>, hashKey: string): string {
const message = JSON.stringify(data);
return createHmac('sha256', hashKey).update(message).digest('base64');
}


3. Verification data​

[
{
"webhookIdx": 172,
"webhookTargetIdx": 347066,
"webhookTargetDataScheme": "TRANSACTION_1",
"data": {
"memo": null,
"txid": "0x46ac495ea3374510bb3dfd97cc28baa31526196cf19093bc62206779296979a6",
"type": "DEPOSIT",
"uuid": "ddb7d66e-dd67-4bef-8f68-fb70aab652db",
"nonce": 45705,
"amount": "0.10000000000000000000",
"status": "FINALIZED",
"symbol": "KAIA",
"usedFee": "0.00077500000000000000",
"toAddress": "0x01ac8A8624B44Ede413Dd3390f1E48A8d512bD2A",
"failedDate": null,
"blockHeight": "122645073",
"createdDate": "2023-05-16T07:30:15.790Z",
"fromAddress": "0x55Bc4ba7A86A00C8A1A09C59DcC32eA2E7FAbCd4",
"outputIndex": 0,
"toAddresses": [
"0x01ac8A8624B44Ede413Dd3390f1E48A8d512bD2A"
],
"modifiedDate": "2023-05-16T07:30:26.000Z",
"finalizedDate": "2023-05-16T07:30:26.000Z",
"fromAddresses": [
"0x55Bc4ba7A86A00C8A1A09C59DcC32eA2E7FAbCd4"
],
"contractAddress": null,
"feePayerAddress": "0x73b14def9a8b01525cb4eff356e01ce611d356aa",
"unfinalizedDate": "2023-05-16T07:30:16.000Z",
"useFeeDelegation": true,
"transactionCurrency": {
"krw": "226.99282922",
"usd": "0.16965089"
}
}
}
]
hash key: d0fd4a49b59dc3aef63ede1e6f4c32a15e94609df0c0fba00b2271080dd13435
webhookTargetDataHash: hi0Eq7xPEingesTPM+fVNwjCgaaZb5lZRTBRxeMwSqA=


4. Example of the delivered webhook data​

[
{
"webhookIdx": 172,
"webhookTargetIdx": 347066,
"webhookTargetDataScheme": "TRANSACTION_1",
"webhookTargetDataHash": "hiphZyBZ+jtKS4/XKiDAOagA7ex2S3Kg34+h1OqEAs8=",
"data": {
"memo": null,
"txid": "0x46ac495ea3374510bb3dfd97cc28baa31526196cf19093bc62206779296979a6",
"type": "DEPOSIT",
"uuid": "ddb7d66e-dd67-4bef-8f68-fb70aab652db",
"nonce": 45705,
"amount": "0.10000000000000000000",
"status": "FINALIZED",
"symbol": "KAIA",
"usedFee": "0.00077500000000000000",
"toAddress": "0x01ac8A8624B44Ede413Dd3390f1E48A8d512bD2A",
"failedDate": null,
"blockHeight": "122645073",
"createdDate": "2023-05-16T07:30:15.790Z",
"fromAddress": "0x55Bc4ba7A86A00C8A1A09C59DcC32eA2E7FAbCd4",
"outputIndex": 0,
"toAddresses": [
"0x01ac8A8624B44Ede413Dd3390f1E48A8d512bD2A"
],
"modifiedDate": "2023-05-16T07:30:26.000Z",
"finalizedDate": "2023-05-16T07:30:26.000Z",
"fromAddresses": [
"0x55Bc4ba7A86A00C8A1A09C59DcC32eA2E7FAbCd4"
],
"contractAddress": null,
"feePayerAddress": "0x73b14def9a8b01525cb4eff356e01ce611d356aa",
"unfinalizedDate": "2023-05-16T07:30:16.000Z",
"useFeeDelegation": true,
"transactionCurrency": {
"krw": "226.99282922",
"usd": "0.16965089"
}
}
}
]