This directory contains the Soroban smart contracts for Nestera, implementing a cost-efficient "Off-Chain Oracle" architecture. This allows users to pay for gas fees while ensuring all minting requests are cryptographically authorized by the Admin.
- Admin Authorization: The Admin generates a cryptographic signature for a
MintPayloadoff-chain using their Ed25519 private key. - User Submission: The user receives the payload and signature and submits them to the
mintfunction on-chain. - On-Chain Verification: The contract verifies the signature against the stored Admin public key before allowing the minting process to proceed.
The Admin must sign the MintPayload using an Ed25519 private key. The payload must be serialized to XDR format to ensure consistency with the on-chain verification.
Using the ed25519-dalek library:
use ed25519_dalek::{Signer, SigningKey};
use soroban_sdk::xdr::ToXdr;
// 1. Create the payload
let payload = MintPayload {
user: user_address,
amount: 100,
timestamp: current_time,
expiry_duration: 3600,
};
// 2. Serialize to XDR
let payload_bytes = payload.to_xdr(&env);
// 3. Sign with Admin private key
let signature = signing_key.sign(&payload_bytes);Users call the mint function themselves, providing the authorized payload and the signature.
stellar contract invoke \
--id <CONTRACT_ID> \
--source <USER_IDENTITY> \
--network testnet \
-- mint \
--payload '{ "user": "...", "amount": 100, "timestamp": 1737511200, "expiry_duration": 3600 }' \
--signature <64_BYTE_HEX_SIGNATURE>- Signature Verification: The contract uses
env.crypto().ed25519_verify()to ensure the signature is valid. - Expiry Protection: Each payload includes a
timestampandexpiry_duration. The contract panics if the current ledger time exceeds the expiry. - Tamper Resistance: Any change to the payload (e.g., increasing the amount) will result in an invalid signature and a contract panic.
cargo build --target wasm32-unknown-unknown --releasecargo test