Node.js
Requirements
npm install ethersFull Example
import { ethers } from "ethers";
const WALLET_KEY = "0xYourPrivateKey"; // never commit this
const BASE_URL = "https://bv7x.ai";
async function main() {
const wallet = new ethers.Wallet(WALLET_KEY);
const timestamp = Math.floor(Date.now() / 1000);
// Step 1: Sign verification message
const message = `Verify BV7X balance: ${wallet.address}:${timestamp}`;
const signature = await wallet.signMessage(message);
// Step 2: Verify wallet and get bearer token
const verifyRes = await fetch(`${BASE_URL}/api/bv7x/oracle/verify`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
wallet: wallet.address,
signature,
timestamp,
}),
});
const { token, tier, balance } = await verifyRes.json();
console.log(`Tier: ${tier}, Balance: ${balance}`);
// Step 3: Fetch the oracle signal
const signalRes = await fetch(`${BASE_URL}/api/bv7x/oracle`, {
headers: { Authorization: `Bearer ${token}` },
});
const signal = await signalRes.json();
console.log(`Signal: ${signal.signal}`);
console.log(`Direction: ${signal.direction}`);
console.log(`Confidence: ${signal.confidence}`);
console.log(`Regime: ${signal.regime}`);
console.log(`BTC: $${signal.btcPrice.toLocaleString()}`);
}
main().catch(console.error);Output
Notes
Next
Last updated