createTimestampedProof
Creates a timestamped proof demonstrating the existence of specific data (data) at a particular point in time.
This function combines the data with the current timestamp, computes a hash (outProof), and fetches the latest Solana outBlockhash. This blockhash serves as an on-chain anchor, proving the proof was created before that block.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | const String& | The data to be timestamped. |
outProof | String& | Output: The combined hash of data and timestamp. |
outTimestamp | uint64_t& | Output: The Unix timestamp used when creating the proof. |
outBlockhash | String& | Output: The latest Solana blockhash used as an anchor. |
Return Value
bool: Returnstrueif the proof is created and the blockhash is fetched successfully.
Example Code (main.cpp)
#include <Arduino.h>
#include <WiFi.h>
#include "Infratic-lib.h"
// --- WiFi Settings ---
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
// --- Solana Settings ---
const String SOLANA_RPC_URL = "[https://api.devnet.solana.com](https://api.devnet.solana.com)";
Infratic solana(SOLANA_RPC_URL);
void setup() {
Serial.begin(115200);
delay(1000);
// Connect to WiFi
Serial.print("Connecting to WiFi...");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\n✅ WiFi connected!");
Serial.println("\n=== createTimestampedProof Example ===");
String dataToTimestamp = "This document was created on 10/10/2025.";
String proof;
uint64_t timestamp;
String blockhash;
Serial.println("Creating timestamped proof and fetching blockhash from Solana...");
if (solana.createTimestampedProof(dataToTimestamp, proof, timestamp, blockhash)) {
Serial.println("✅ Timestamped proof created successfully!");
Serial.println(" -> Proof (Hash): " + proof);
Serial.print(" -> Timestamp: ");
Serial.println((unsigned long)timestamp);
Serial.println(" -> Solana Blockhash (Anchor): " + blockhash);
} else {
Serial.println("❌ Failed to create proof (Could not fetch blockhash).");
}
}
void loop() {
// Can be left empty
}