trade-signal
⚠ Advisory only — not financial advice; no orders executed. This kit generates AI buy/sell/hold signals for informational purposes only. It does not place orders, move funds, or execute any transaction on your behalf. You are solely responsible for any decisions you make. This is a testnet demo running on the Galileo network — mainnet and automated execution are intentionally out of scope.
What it does
The trade-signal kit adds an advisory trading-signal feature to your 0G
app. The public API has no execute, trade, swap, send, or
transfer function — this is a signal generator with an attested audit trail,
not an auto-trader.
On each run the kit:
- Accepts a read-only
SignalInput(asset, current price, recent price history, optional indicators) from the caller — no on-chain read is performed by the lib. - Calls
@foundryprotocol/0gkit-computeviacompute.router()(K7 — routed provider selection with a client-side fallback) with a structured prompt asking for an advisory action, a confidence, and a one-sentence rationale. The model is instructed: no order instructions, no profit guarantees, no risk-free claims. - Parses the JSON response and returns a validated
Signal(action ∈ buy|sell|hold,confidenceclamped to[0,1],rationale). On malformed output it returns a safeholddefault (confidence0) — it never fabricates a buy/sell and never throws. - Optionally attests the signal:
logSignalsigns aSignalReceiptvia EIP-191 personal-sign and uploads the full record to 0G Storage as an immutable audit entry;attestSignalsigns + verifies a receipt without storing (used by the MCP tool). Neither executes anything.
The AdvisoryBanner component is non-removable — it is rendered
unconditionally at the top of the signal page with fixed copy:
"Advisory only — not financial advice; no orders executed."
Compatible bases
react-app · chat · tee-attested-api · mcp-agent
Apply
# scaffold-time
npm create 0gkit-app -- --kits trade-signal
# add to an existing project
0g add trade-signal
Environment variables
| Variable | Example | Notes |
|---|---|---|
OG_PRIVATE_KEY | 0x... | Operator key for signing signal receipts and 0G Storage transactions |
OG_RPC_URL | https://evmrpc-testnet.0g.ai | 0G chain RPC endpoint (Galileo testnet default — mainnet is out of scope) |
OG_COMPUTE_MODEL | neuralmagic/Meta-Llama-3.1-70B-Instruct-FP8 | Model for signal inference (optional — uses provider default if omitted) |
OG_ATTESTOR_ADDRESS | 0x... | Expected signer address the signal_verify MCP tool (and the sign+verify path) checks against |
Quick start
0g add trade-signal
analyzeSignal(input, deps) returns an advisory, read-only Signal.
logSignal(signal, deps) records the signal as a signed receipt on 0G Storage —
it does not execute anything:
import { Compute } from "@foundryprotocol/0gkit-compute";
import { fromPrivateKey } from "@foundryprotocol/0gkit-wallet";
import { analyzeSignal, type SignalInput } from "./lib/signal.js";
const privateKey = process.env.OG_PRIVATE_KEY as `0x${string}`;
const signer = await fromPrivateKey(privateKey);
const compute = new Compute({ signer });
const input: SignalInput = {
asset: "ETH",
currentPrice: 3200,
history: [3100, 3150, 3180, 3200],
indicators: { rsi14: 58, sma20: 3120 },
};
const signal = await analyzeSignal(input, {
compute: {
async infer({ prompt, model }) {
const r = await compute.router({
messages: [{ role: "user" as const, content: prompt }],
...(model ? { model } : {}),
});
return { output: r.output };
},
},
model: process.env.OG_COMPUTE_MODEL,
}); // { action: "buy"|"sell"|"hold", confidence: 0..1, rationale }; safe "hold" on malformed output
console.log(signal);
Honesty caveat:
trade-signalis advisory-only by design — the public API has noexecute/trade/swap/send/transfer(enforced by a negative test).logSignalrecords the signal with a signed receipt (not a TEE-quote); the user decides and acts manually. Testnet-default; mainnet and automated execution are intentionally out of scope.
Tiers
- lib —
lib/signal.ts(portableanalyzeSignal,Signal,SignalInput,SignalAction,AnalyzeSignalDeps— the only analysis function; read-only, safeholddefault);lib/signalLog.ts(portablelogSignal+attestSignal,SignalReceipt,SignalRecord,SealedSignal— attest to 0G Storage or sign+verify without storing; neither executes a transaction). - adapters —
app/api/signal/route.tsforreact-appandchatbases (POST dispatcher:analyze+log);src/routes/signal.tsfortee-attested-api(HonobuildSignalRouter);src/tools/signal.tsformcp-agent(trade_signal+signal_verifyMCP tools +mcpToolPlugin). - ui —
components/AdvisoryBanner.tsx(non-removable disclaimer, leads the page),components/SignalPanel.tsx(advisory action badge + attested receipt button),hooks/useTradeSignal.ts,app/signal/page.tsx.
Attested signal receipt
logSignal (lib/signalLog.ts) records the advisory signal with an attested
receipt:
- Builds a canonical
SignalReceipt(asset,action,confidence,rationale,ts). - Signs it via the injected
Attestor(EIP-191 personal-sign overdigestJson(receipt)). Badge: ✓ signature verified — not TEE-quote. - Encodes the full
SignalRecordto JSON and uploads to 0G Storage (immutable, content-addressed). ThestorageRefis the returned root. - Returns the full record including
storageReffor offline retrieval and independent verification.
The mcp-agent adapter exposes the same attestation as two tools:
trade_signal (returns an advisory signal + a signed, verified receipt) and
signal_verify (recovers the signer from a receipt and checks it against the
expected operator address). Neither tool places an order.
Honesty note
trade-signal is deliberately advisory-only. The lib test suite contains a
negative assertion (PUBLIC API SURFACE — advisory-only, execution-free invariant) that fails if any export ever contains execute, trade, swap,
send, or transfer — this guard exists for the lifetime of the kit.
The attestation is a signed receipt (EIP-191 personal-sign via
@foundryprotocol/0gkit-attestation recoverSigner) — not a TEE-quote /
enclave attestation. The Attestor interface is injected so a real TEE-quote
verifier can slot in without changing the lib.
OG_RPC_URL defaults to the Galileo testnet endpoint. Mainnet usage and
automated execution are intentionally out of scope for this kit.