@survivorshield/shield
v1.0.1
Published
Drop-in SDK for Shield Router Oracle — risk-aware execution control for Solana
Maintainers
Readme
@survivorshield/shield
Drop-in SDK for Shield Router Oracle — risk-aware execution control for Solana.
Zero dependencies. Works in Node 16+.
Install
npm install @survivorshield/shieldQuick Start
const { createShield } = require("@survivorshield/shield");
const shield = createShield({
apiKey: process.env.SURVIVOR_KEY,
});
// Gate a swap in 3 lines
const gate = await shield.attestAndGate({
mint: "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
amountUsd: 2500,
});
if (gate.allow) {
executeSwap();
} else if (gate.challenge) {
reducePosition(gate.limits.max_amount_usd);
} else {
console.log("DENY:", gate.reasonCodes);
}Get an API Key
GET /billing/plans— view credit packagesPOST /billing/checkout {"plan":"starter"}— get Stripe checkout URL- Complete payment — receive API key + 1,000 credits
API
createShield(opts)
| Option | Type | Required | Default |
|--------|------|----------|---------|
| apiKey | string | yes | — |
| baseUrl | string | no | Production URL |
| routerProgramId | string | no | Shield Router v1 |
| timeoutMs | number | no | 10000 |
shield.attestAndGate(params) — Primary method
const gate = await shield.attestAndGate({
mint: "TOKEN_MINT",
amountUsd: 500,
throwOnDeny: true,
});
// gate.allow, gate.challenge, gate.deny
// gate.score, gate.riskLevel, gate.limits
// gate.charged, gate.creditsRemaining
// gate.attestation, gate.signatureshield.attest(mint) — Raw attestation
shield.quote({ score, amountUsd }) — Preflight (no charge)
shield.balance() — Check credits
shield.verify(response) — Verify attestation
shield.whoami() / shield.ledger() / shield.pricing() / shield.plans()
Credit Costs
| Risk Level | Multiplier | Calm | Mania | |-----------|-----------|------|-------| | LOW | 1x | 1 | 2 | | MEDIUM | 1.5x | 2 | 3 | | HIGH | 2.5x | 3 | 4 | | VERY_HIGH | 4x | 4 | 6 | | EXTREME | 8x | 8 | 12 |
Error Handling
try {
const gate = await shield.attestAndGate({ mint, throwOnDeny: true });
} catch (err) {
if (err.status === 402) console.log("Out of credits");
if (err.status === 429) console.log("Rate limited");
if (err.gate) console.log("Denied:", err.gate.reasonCodes);
}Links
- API Docs
- Buy Credits
- Built by @youngs_modulus
