Sensor-to-Chain Demo
- Source:
sensor_to_chain_demo.ino - Prerequisites: supported sensor + devnet RPC.
- Shows: sensor read, compact encoding, transaction submit loop for telemetry publishing.
Code
int64_t sensorValue = readSensorValue();
int64_t timestamp = (int64_t)(millis() / 1000);
Instruction ix;
ix.setProgram(programId);
ix.addKey(authorityPub, true, true);
ix.addKey(dataAccountPda, false, true);
ix.addKey(SystemProgram::PROGRAM_ID, false, false);
ix.writeBytes(RECORD_DATA_DISCRIMINATOR, 8);
ix.writeI64LE(sensorValue);
ix.writeI64LE(timestamp);Last updated on