Utility API
utils.verifyReceipt(receipt)
Returns true or false, indicating if a receipt is valid or not.
Parameters
| Name | Type | Description |
|---|---|---|
| receipt | object | The receipt as a JSON object. |
The receipt object should have the following format:
{
id, // Transaction ID
public, // Public key of the bundler node used
signature, // A signed deep hash of the JSON receipt
deadlineHeight, // The block number by which the transaction must be finalized
timestamp, // Timestamp (UNIX milliseconds) of when the transaction was created and verified
version, // The version of this JSON file, currently 1.0.0
}Returns
| Type | Description |
|---|---|
| boolean | A true or false value indicating if the receipt is valid. |
Example
Note
Use a token-specific version of
getIrysUploader() to connect to an Irys Bundler before uploading. Choose one from the setup documentation.const irys = await getIrysUploader();
try {
// First get a receipt
const transactionID = "i9tgbHsr6c1sxryAQ-SLM2rfQAYRuyap7RmGgH28mI4"; // Your transaction ID
const receipt = await irys.utils.getReceipt(transactionID);
// Then verify it
const isReceiptValid = await irys.utils.verifyReceipt(receipt);
console.log(isReceiptValid);
} catch (e) {
console.log("Error getting receipt ", e);
}