forked from douglasborthwick-crypto/insumer-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.sh
More file actions
executable file
·85 lines (69 loc) · 2.29 KB
/
quickstart.sh
File metadata and controls
executable file
·85 lines (69 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# InsumerAPI Quickstart — get a key and verify a wallet in two commands.
# Usage: INSUMER_EMAIL=you@example.com bash quickstart.sh
set -euo pipefail
API="https://api.insumermodel.com"
KEY_URL="https://api.insumermodel.com/v1/keys/create"
EMAIL="${INSUMER_EMAIL:-you@example.com}"
APP_NAME="${INSUMER_APP_NAME:-quickstart-demo}"
# --- Step 1: Get a free API key ---
echo "Getting API key for ${EMAIL}..."
KEY_RESPONSE=$(curl -s -X POST "$KEY_URL" \
-H "Content-Type: application/json" \
-d "{\"email\": \"${EMAIL}\", \"appName\": \"${APP_NAME}\", \"tier\": \"free\"}")
API_KEY=$(echo "$KEY_RESPONSE" | python3 -c "import sys,json; print(json.load(sys.stdin).get('key',''))" 2>/dev/null)
if [ -z "$API_KEY" ]; then
echo "Key creation response: $KEY_RESPONSE"
echo ""
echo "If you already have a key, set it: INSUMER_API_KEY=insr_live_... bash quickstart.sh"
API_KEY="${INSUMER_API_KEY:-}"
if [ -z "$API_KEY" ]; then
exit 1
fi
else
echo "Got key: ${API_KEY:0:20}..."
fi
# --- Step 2: Verify a wallet holds SHIB on Ethereum ---
echo ""
echo "Verifying wallet holds SHIB on Ethereum..."
ATTEST_RESPONSE=$(curl -s -X POST "$API/v1/attest" \
-H "Content-Type: application/json" \
-H "X-API-Key: $API_KEY" \
-d '{
"wallet": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"conditions": [
{
"type": "token_balance",
"contractAddress": "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE",
"chainId": 1,
"threshold": 1000000,
"label": "SHIB holder"
}
]
}')
echo "$ATTEST_RESPONSE" | python3 -m json.tool
# --- Step 3: Check credit balance ---
echo ""
echo "Checking remaining credits..."
CREDITS_RESPONSE=$(curl -s "$API/v1/credits" \
-H "X-API-Key: $API_KEY")
echo "$CREDITS_RESPONSE" | python3 -m json.tool
# --- Step 4: Verify XRPL wallet holds XRP ---
echo ""
echo "Verifying XRPL wallet holds XRP..."
XRPL_RESPONSE=$(curl -s -X POST "$API/v1/attest" \
-H "Content-Type: application/json" \
-H "X-API-Key: $API_KEY" \
-d '{
"xrplWallet": "rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn",
"conditions": [
{
"type": "token_balance",
"contractAddress": "native",
"chainId": "xrpl",
"threshold": 100,
"label": "XRP >= 100"
}
]
}')
echo "$XRPL_RESPONSE" | python3 -m json.tool