Official Rust SDK for Shieldz — non-custodial crypto payments with $0 fees.
Accept USDC/USDT across Base, Arbitrum, Optimism, Polygon, and Ethereum, plus native Bitcoin and shielded Zcash. Funds settle straight to your own wallet — Shieldz never holds them, and never asks for your keys.
[dependencies]
shieldz = "0.1"use shieldz::Shieldz;
use serde_json::json;
let shieldz = Shieldz::new(std::env::var("SHIELDZ_API_KEY")?);
let invoice = shieldz.invoices().create(json!({
"amount_usd_cents": 5000, // $50.00
"memo": "Order #1234",
"metadata": { "order_id": "1234" },
}))?;
println!("{} {}", invoice["status"], invoice["pay_url"]);
// → send your customer to invoice["pay_url"] (the hosted checkout)
# Ok::<(), Box<dyn std::error::Error>>(())let inv = shieldz.invoices().retrieve("Qgvz8WQw0mnv2M8")?;
let page = shieldz.invoices().list(&[("limit", "20".into()), ("status", "paid".into())])?;
let all = shieldz.invoices().list_all(&[("status", "paid".into())])?; // follows the cursorRetryable POSTs get an auto idempotency_key so a retried create can't duplicate; pass your own to tie it to an order.
Sell from a catalog, the way Stripe does: prices live in Shieldz, so a buyer's browser can never change what they pay.
let hoodie = shieldz.products().create(json!({
"name": "Blue hoodie",
"default_price_data": { "unit_amount_usd_cents": 4999 },
}))?;
// A hosted page (link["url"]) and the target of the widget's buy button:
// <button data-shieldz-link="plink_…">Buy now</button>
let link = shieldz.payment_links().create(json!({
"line_items": [{ "product": hoodie["id"], "adjustable_quantity": { "enabled": true, "maximum": 5 } }],
"collect_shipping_address": true,
}))?;
// Or price an order on your server:
let invoice = shieldz.invoices().create(json!({
"line_items": [
{ "price": hoodie["default_price"]["id"], "quantity": 2 },
{ "price_data": { "name": "Gift wrap", "unit_amount_usd_cents": 300 } },
],
"client_reference_id": "A-1043",
}))?;Paid invoices carry line_items, payment_link, client_reference_id and,
when the link asked for it, shipping.
Products and payment links have no test mode: a link takes real payments
whichever key made it. To try a priced checkout without real money, create an
invoice with line_items and an sk_test_ key. A checkout's total must be
from $1 to $100,000. The full walkthrough is in
examples/catalog.rs (cargo run --example catalog).
Verify against the raw request body:
use shieldz::{construct_event, VerifyOptions};
let event = construct_event(
raw_body, // &[u8]
signature_header, // X-Shieldz-Signature
&signing_secret, // whsec_…
&VerifyOptions::default(), // 300s tolerance
)?;
if event["type"] == "invoice.paid" {
// fulfill — dedupe on X-Shieldz-Delivery (at-least-once)
}
# Ok::<(), shieldz::SignatureVerificationError>(())verify_signature(...) is also available if you just want a Result<(), _>. During the 24h after a secret rotation the header carries both signatures and either matches.
Any non-2xx returns ShieldzError { status, kind, code, message, param, request_id }.
- Docs / API quickstart: https://shieldz.cash/docs
- Is it safe? (non-custodial proof): https://shieldz.cash/verify
- Node SDK: https://github.com/ShieldZCash/shieldz-sdk · Python SDK: https://github.com/ShieldZCash/shieldz-python
MIT © Deniz Yanbollu / Shieldz