Multichain
Search…
πŸ””
Notify URL (Webhook)
Save a project webhook url to receive subwallet deposit callback/notifications.
Step 1: Select "Configure Webhook" from "Projects" on Dashboard.
Configure webhook
Step 2: Input your webhook URL into the field provided and click "Save"
Save your webhook callback url under "Projects"
Step 3: Send test notification to webhook url for development purposes.
"Send test notification" option

πŸ”” Sample notification POSTto your webhook url

1
{
2
"type": "DEPOSIT",
3
"network": "TRON",
4
"status": "SUCCESS",
5
"hash": "cd2df87daa2001c678f5be970851278987a45132f165f62e5f1e1987c43d5cf7",
6
"fromAddress": "TDmarSrhZg7LaUaQyzez7UA2EZrCLWXEjw",
7
"toAddress": "TTcVb5oLA7UDGCDvTs7DtQo9ktJWgYPCkC",
8
"contractAddress": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
9
"value": "787.41",
10
"assetName": "Tether USD",
11
"assetSymbol": "USDT",
12
"networkFee": "1",
13
"platformFee": "3.93705",
14
"timestamp": 1618564124
15
}
Copied!
Go to https://webhook.site/ and use the given unique url to immediately inspect and test notifications sent by Multichain.
Step 4:
πŸ”₯
Validating data received at callback URL (Webhook) It is considered standard practice to respond with 200 OK once you have successfully received a webhook callback (notification).
Javascript
Python
1
function isValidSignature(request) {
2
const secretKey = 'Secret Key provided by Multichain on the Project (View Key) list popup';
3
const headers = request.headers;
4
const signature = headers['multichain-api-key']; // Lowercase for NodeJS
5
const body = request.body;
6
const hmac = crypto.createHmac('sha256', secretKey) // Create a HMAC SHA256 hash using the auth token
7
hmac.update(body, 'utf8') // Update the token hash with the request body using utf8
8
const digest = hmac.digest('hex');
9
return (signature === digest); // If signature equals your computed hash, return true
10
}
Copied!
1
import hmac
2
import hashlib
3
import json
4
def isValidSignature(request):
5
secretKey = '<your Secret Key goes here>';
6
headers = request['headers'];
7
signature = headers['multichain-api-key'];
8
body = request['body'];
9
string_body = json.dumps(body, separators=(',', ':'))
10
11
digest = hmac.new(
12
bytes(secretKey, 'utf-8'),
13
msg=bytes(string_body, 'utf-8'),
14
digestmod=hashlib.sha256
15
).hexdigest()
16
17
return (signature == digest);
Copied!
Make sure only to store validated transactions by type DEPOSIT using hash as the unique - primary key which will reject and prevent duplicated deposits in any case where your system receives a repeated webhook notification.
Note that webhook notification max retry is
5
times; Notification will stop if no 200 OK response from your application is received within the retries.
πŸ””
You may however manually re-send the notification from the user dashboard under the "Subwallet Deposits" tab. (Image reference below.)
Re-send webhook notification to your application manually.
Last modified 13d ago