Docs

Quickstart

Read a Noir card policy and check a payment in five minutes, with the SDK or the REST API.

Option A — the SDK

Install it next to the Stellar SDK:

bash
npm install @noir-wallet/agent-sdk @stellar/stellar-sdk

Read a card’s policy and ask the contract whether a payment would go through. Reads need no account and no key.

check.ts
import { NoirAgentClient } from '@noir-wallet/agent-sdk'

const noir = new NoirAgentClient() // Noir's Testnet contracts are built in

const deviceHash = process.argv[2] // 64 hex chars, from the tap
const policy = await noir.getPolicy(deviceHash)
console.log(policy) // { agent, maxAmount, asset, expiresAt } or null

if (policy) {
  const check = await noir.checkPayment({
    deviceHash, agent: policy.agent, asset: policy.asset, amount: 10_000_000n, // 1 XLM
  })
  console.log(check) // { ok: true } or { ok: false, reason: 'over_limit' | 'expired' | … }
}

To charge the card, the agent key signs authorizePayment; the merchant later calls claim. See the SDK reference.

Option B — the REST API

Run the gateway (or use one your team hosts) and create a key:

bash
git clone https://github.com/rylsherdamz-rgb/Noir_Wallet && cd Noir_Wallet/sdk/noir-api
npm run setup && npm run build
npm run keygen -- my-shop --scopes read,write,webhooks   # prints noir_sk_… once
npm start                                                 # http://localhost:8787

Then call it from anything that speaks HTTP:

bash
export NOIR_KEY=noir_sk_xxxxxxxx_…

curl http://localhost:8787/v1/devices/$DEVICE_HASH -H "Authorization: Bearer $NOIR_KEY"

curl -X POST http://localhost:8787/v1/payments/check -H "Authorization: Bearer $NOIR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"deviceHash":"'$DEVICE_HASH'","agent":"G…","asset":"C…","amount":"10000000"}'

Next