> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yield.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Shield integration

> Run Shield as a TypeScript library, a standalone binary from any language, or server-side via Defense Mode.

Shield runs wherever your signing flow lives. Pick the path that matches your stack: the TypeScript library for Node.js and browser integrations, the standalone binary for every other language and for restricted environments, or server-side enforcement inside the Earn API via Defense Mode.

## Choosing an integration path

| Path | How it runs | Recommended for |
| - | - | - |
| **TypeScript library** | `@yieldxyz/shield` npm package, in-process | Wallets, web apps, Node.js backends, hosted widget integrations |
| **Standalone binary** | Pre-built executable, JSON over stdin/stdout, callable from any language | Go/Python/Rust backends, exchanges, custodians, secure or air-gapped environments |
| **Defense Mode (server-side)** | Shield embedded in the Earn API's transaction pipeline, in Monitor or Block mode | Any integration: it requires no client-side changes |

You can combine these paths. Defense Mode validates transactions inside the API, and client-side Shield validates them again after they reach you. Running both gives you two independent checkpoints. See [Security deployment options](https://docs.yield.xyz/documentation/security/shield/security-tiers.md) for how to combine them.

## TypeScript library

```bash theme={null}
npm install @yieldxyz/shield
```

Instantiate `Shield` and call `validate()` on every transaction before signing. The [Shield overview](https://docs.yield.xyz/documentation/security/shield.md) walks through the full quick start and API reference.

## Standalone binary

The binary embeds the full validator set and vault registry, requires no Node.js installation, and accepts JSON on stdin. Download the build for your platform from the [latest release](https://github.com/stakekit/shield/releases/latest):

| Platform | Binary |
| - | - |
| Linux x64 | `shield-linux-x64` |
| macOS ARM (Apple Silicon) | `shield-darwin-arm64` |
| macOS Intel | `shield-darwin-x64` |
| Windows x64 | `shield-windows-x64.exe` |

**1. Download the binary**

```bash theme={null}
curl -LO https://github.com/stakekit/shield/releases/latest/download/shield-darwin-arm64
chmod +x shield-darwin-arm64
```

**2. Verify integrity**

```bash theme={null}
curl -LO https://github.com/stakekit/shield/releases/latest/download/shield-darwin-arm64.sha256
shasum -a 256 -c shield-darwin-arm64.sha256  # Expected output: OK
```

Every release also includes [GitHub artifact attestations](https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds): cryptographic proof that each binary was built by the Shield CI pipeline and not modified after the fact. Verify with the GitHub CLI:

```bash theme={null}
gh attestation verify shield-darwin-arm64 --repo stakekit/shield
```

**3. Send a validation request**

Every request requires `apiVersion` and an `operation` field (`validate`, `isSupported`, or `getSupportedYieldIds`):

```bash theme={null}
echo '{
  "apiVersion": "1.0",
  "operation": "validate",
  "unsignedTransaction": "0x...",
  "yieldId": "ethereum-eth-lido-staking",
  "userAddress": "0x..."
}' | ./shield-darwin-arm64
```

```json Response theme={null}
{
  "ok": true,
  "apiVersion": "1.0",
  "result": {
    "isValid": true,
    "detectedType": "STAKE"
  },
  "meta": {
    "requestHash": "a3f2c1..."
  }
}
```

> [!NOTE]
>
> **Library vs binary response shapes.** The TypeScript library (`shield.validate()`) returns the unwrapped `result` object directly. The binary protocol wraps it in `{ ok, apiVersion, result, meta }` so non-TypeScript integrations can correlate requests via `meta.requestHash` and handle protocol-level errors separately from validation failures.

### Language guides

Call the binary as a subprocess from your language of choice. Full worked examples live in the Shield repository:

* [Go integration guide](https://github.com/stakekit/shield/blob/main/docs/integration-go.md)
* [Python integration guide](https://github.com/stakekit/shield/blob/main/docs/integration-python.md)
* [Rust integration guide](https://github.com/stakekit/shield/blob/main/docs/integration-rust.md)

### Restricted and on-premises environments

Because the binary is self-contained and validation is fully local (the embedded vault registry means no network calls), you can run Shield inside your own infrastructure: compiled backends, locked-down hosts, or air-gapped signing environments. Institutional partners with requirements beyond the standalone binary, such as dedicated deployments with custom policy control, should [contact the Yield.xyz team](mailto:hello@yield.xyz) to scope a setup.

## Server-side enforcement: Defense Mode

Shield also runs inside the Earn API itself, validating every constructed transaction before it is returned. It runs in Monitor mode (validate and log) by default; in Block mode, enabled per project, transactions that fail validation are rejected server-side.

This path requires no code changes on your end. See [Defense Mode](https://docs.yield.xyz/documentation/security/shield/index.md#defense-mode) for the modes and threat model.

## Redundancy and failover

* **Client-side independence**: because the Shield library and binary validate locally with an embedded registry, client-side validation keeps working even during an upstream outage.

## Next steps

> [card] [Shield overview](https://docs.yield.xyz/documentation/security/shield.md)
>
> Quick start and API reference

> [card] [Shield features](https://docs.yield.xyz/documentation/security/shield/features.md)
>
> Coverage matrix and validation errors

> [card] [Security deployment options](https://docs.yield.xyz/documentation/security/shield/security-tiers.md)
>
> Combine client-side and server-side enforcement


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.