@agentsbank/sdk 1.0.10 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-config.d.ts","sourceRoot":"","sources":["../security-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCAwIP,MAAM,GAAG,SAAS,KAAG,OAAO;sCAU5B,MAAM,GAAG,SAAS,KAAG,OAAO;mDAKf,MAAM,KAAG,OAAO;yCAI1B,MAAM,KAAG,OAAO;;CAKlC,CAAC;AAEX;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CA4B1E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CAgC/D;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,IAAI,CAoBN"}
@@ -0,0 +1,229 @@
1
+ /**
2
+ * AgentsBank SDK Security Configuration
3
+ *
4
+ * Defines security constraints and validation rules for the SDK
5
+ * To be used during development and deployment validation
6
+ */
7
+ export const SDK_SECURITY_CONFIG = {
8
+ // ============================================
9
+ // Required Credentials
10
+ // ============================================
11
+ requiredCredentials: [
12
+ 'AGENTSBANK_API_URL',
13
+ 'AGENTSBANK_API_KEY | (AGENTSBANK_AGENT_USERNAME + AGENTSBANK_AGENT_PASSWORD)'
14
+ ],
15
+ // ============================================
16
+ // Risk Assessment
17
+ // ============================================
18
+ riskLevel: 'HIGH', // Financial transaction platform
19
+ financialOperations: true,
20
+ autonomousExecutionAllowed: false, // DEFAULT: Must not be autonomously invocable
21
+ autonomousModeSupportedButOptional: true, // Can be enabled via config flag if needed
22
+ defaultRequiresApproval: true, // By default, all transactions require approval
23
+ // ============================================
24
+ // Credential Scope & Constraints
25
+ // ============================================
26
+ credentialScopes: {
27
+ 'AGENTSBANK_API_URL': {
28
+ required: true,
29
+ type: 'url',
30
+ description: 'Base URL of AgentsBank API',
31
+ example: 'https://api.agentsbank.ai',
32
+ defaultIfMissing: null, // NO DEFAULT - must be explicit
33
+ },
34
+ 'AGENTSBANK_API_KEY': {
35
+ required: false,
36
+ type: 'secret',
37
+ description: 'API Key for authentication (recommended)',
38
+ example: 'sk_live_...',
39
+ rotationInterval: 30 * 24 * 60 * 60 * 1000, // 30 days in ms
40
+ defaultIfMissing: null,
41
+ },
42
+ 'AGENTSBANK_AGENT_USERNAME': {
43
+ required: false,
44
+ type: 'string',
45
+ description: 'Agent username (alternative auth method)',
46
+ example: 'agent_123',
47
+ defaultIfMissing: null,
48
+ },
49
+ 'AGENTSBANK_AGENT_PASSWORD': {
50
+ required: false,
51
+ type: 'secret',
52
+ description: 'Agent password (alternative auth method)',
53
+ example: 'secret_password',
54
+ defaultIfMissing: null,
55
+ },
56
+ },
57
+ // ============================================
58
+ // Financial Operation Constraints
59
+ // ============================================
60
+ financialOperationConstraints: {
61
+ sendTransaction: {
62
+ requiresUserApprovalContext: true, // DEFAULT: Always required
63
+ canBypassApprovalInAutonomousMode: true, // Can be disabled if autonomousMode=true in SDKConfig
64
+ requiresUserId: true,
65
+ requiresApprovalTimestamp: true,
66
+ auditLoggingRequired: true,
67
+ atomicity: 'required', // Must succeed or fail completely
68
+ rollbackOnFailure: true,
69
+ warningIfAutonomous: 'Executing financial transaction WITHOUT human approval',
70
+ },
71
+ createWallet: {
72
+ requiresUserApprovalContext: false, // Optional for wallet creation
73
+ auditLoggingRequired: true,
74
+ typeValidation: ['custodial', 'non-custodial'],
75
+ },
76
+ estimateGas: {
77
+ requiresUserApprovalContext: false,
78
+ auditLoggingRequired: false, // Informational only
79
+ cacheable: true, // Can cache results for same params
80
+ },
81
+ },
82
+ // ============================================
83
+ // Audit Trail Requirements
84
+ // ============================================
85
+ auditRequirements: {
86
+ requiredFields: [
87
+ 'timestamp',
88
+ 'operation',
89
+ 'status',
90
+ 'userId', // For financial operations
91
+ 'walletId', // For wallet operations
92
+ ],
93
+ retention: {
94
+ production: 7 * 365 * 24 * 60 * 60 * 1000, // 7 years
95
+ development: 90 * 24 * 60 * 60 * 1000, // 90 days
96
+ },
97
+ sensitiveOperations: [
98
+ 'transaction_send',
99
+ 'auth_login',
100
+ 'token_refresh',
101
+ 'wallet_create'
102
+ ],
103
+ },
104
+ // ============================================
105
+ // Deployment Constraints
106
+ // ============================================
107
+ deploymentConstraints: {
108
+ allowedEnvironments: ['development', 'staging', 'production'],
109
+ productionRequirements: [
110
+ 'Credentials stored in secrets manager',
111
+ 'Custom audit logger configured',
112
+ 'Rate limiting enabled',
113
+ 'Error monitoring (Sentry, DataDog, etc.)',
114
+ 'Credential rotation scheduled',
115
+ ],
116
+ forbiddenPatternsInCode: [
117
+ 'sk_live_', // API keys should not be in code
118
+ 'sk_sandbox_',
119
+ 'password:',
120
+ 'secret:',
121
+ 'token:',
122
+ ],
123
+ },
124
+ // ============================================
125
+ // Rate Limiting Defaults
126
+ // ============================================
127
+ rateLimiting: {
128
+ transactionsPerMinute: 5,
129
+ maxAmountPerTransaction: '1000', // Max 1000 of currency
130
+ maxDailyAmount: '10000', // Max 10000 per day per agent
131
+ },
132
+ // ============================================
133
+ // Validation Functions
134
+ // ============================================
135
+ validators: {
136
+ isValidApiUrl: (url) => {
137
+ if (!url)
138
+ return false;
139
+ try {
140
+ new URL(url);
141
+ return url.startsWith('https://');
142
+ }
143
+ catch {
144
+ return false;
145
+ }
146
+ },
147
+ isValidApiKey: (key) => {
148
+ if (!key)
149
+ return false;
150
+ return key.startsWith('sk_') && key.length > 20;
151
+ },
152
+ isValidEthereumAddress: (address) => {
153
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
154
+ },
155
+ isValidAmount: (amount) => {
156
+ const num = parseFloat(amount);
157
+ return !isNaN(num) && num > 0;
158
+ },
159
+ },
160
+ };
161
+ /**
162
+ * Validates SDK configuration before use
163
+ * Throws error if validation fails
164
+ */
165
+ export function validateSDKConfiguration(config) {
166
+ // Check required API URL
167
+ if (!config.apiUrl) {
168
+ throw new Error('SECURITY VALIDATION FAILED: AGENTSBANK_API_URL is required. ' +
169
+ 'See SKILL.md for credential requirements.');
170
+ }
171
+ if (!SDK_SECURITY_CONFIG.validators.isValidApiUrl(config.apiUrl)) {
172
+ throw new Error('SECURITY VALIDATION FAILED: Invalid API URL. ' +
173
+ 'Must be HTTPS URL. Example: https://api.agentsbank.ai');
174
+ }
175
+ // Check at least one authentication method
176
+ const hasApiKey = !!config.apiKey && SDK_SECURITY_CONFIG.validators.isValidApiKey(config.apiKey);
177
+ const hasCredentials = config.agentUsername && config.agentPassword;
178
+ const hasToken = !!config.token;
179
+ if (!hasApiKey && !hasCredentials && !hasToken) {
180
+ throw new Error('SECURITY VALIDATION FAILED: No authentication provided. ' +
181
+ 'Provide one of: apiKey, (agentUsername + agentPassword), or token. ' +
182
+ 'See SKILL.md for setup instructions.');
183
+ }
184
+ }
185
+ /**
186
+ * Validates user approval context for financial operations
187
+ */
188
+ export function validateUserApprovalContext(approval) {
189
+ if (!approval) {
190
+ throw new Error('SECURITY ERROR: User approval context required for financial operations. ' +
191
+ 'Cannot execute financial operations autonomously.');
192
+ }
193
+ if (!approval.userId) {
194
+ throw new Error('SECURITY ERROR: approval.userId required. ' +
195
+ 'Must identify human who approved this operation.');
196
+ }
197
+ if (!approval.approvedAt || !(approval.approvedAt instanceof Date)) {
198
+ throw new Error('SECURITY ERROR: approval.approvedAt required (Date object). ' +
199
+ 'Must have timestamp of when approval was granted.');
200
+ }
201
+ // Check approval is recent (within last hour)
202
+ const ageMs = Date.now() - approval.approvedAt.getTime();
203
+ const maxAgeMs = 60 * 60 * 1000; // 1 hour
204
+ if (ageMs > maxAgeMs) {
205
+ throw new Error(`SECURITY ERROR: Approval too old (${Math.round(ageMs / 1000)}s). ` +
206
+ 'User approval must be renewed within 1 hour of transaction.');
207
+ }
208
+ }
209
+ /**
210
+ * Validates financial operation parameters
211
+ */
212
+ export function validateFinancialOperationParams(walletId, toAddress, amount) {
213
+ if (!walletId) {
214
+ throw new Error('walletId is required');
215
+ }
216
+ if (!toAddress) {
217
+ throw new Error('toAddress is required');
218
+ }
219
+ if (!SDK_SECURITY_CONFIG.validators.isValidEthereumAddress(toAddress)) {
220
+ throw new Error(`Invalid Ethereum address: ${toAddress}`);
221
+ }
222
+ if (!amount) {
223
+ throw new Error('amount is required');
224
+ }
225
+ if (!SDK_SECURITY_CONFIG.validators.isValidAmount(amount)) {
226
+ throw new Error(`Invalid amount: ${amount}. Must be a positive number.`);
227
+ }
228
+ }
229
+ //# sourceMappingURL=security-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-config.js","sourceRoot":"","sources":["../security-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,+CAA+C;IAC/C,uBAAuB;IACvB,+CAA+C;IAC/C,mBAAmB,EAAE;QACnB,oBAAoB;QACpB,8EAA8E;KAC/E;IAED,+CAA+C;IAC/C,kBAAkB;IAClB,+CAA+C;IAC/C,SAAS,EAAE,MAAe,EAAE,iCAAiC;IAC7D,mBAAmB,EAAE,IAAI;IACzB,0BAA0B,EAAE,KAAK,EAAE,8CAA8C;IACjF,kCAAkC,EAAE,IAAI,EAAE,2CAA2C;IACrF,uBAAuB,EAAE,IAAI,EAAE,gDAAgD;IAE/E,+CAA+C;IAC/C,iCAAiC;IACjC,+CAA+C;IAC/C,gBAAgB,EAAE;QAChB,oBAAoB,EAAE;YACpB,QAAQ,EAAE,IAAI;YACd,IAAI,EAAE,KAAc;YACpB,WAAW,EAAE,4BAA4B;YACzC,OAAO,EAAE,2BAA2B;YACpC,gBAA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B,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,6BAA6B,SAAS,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,8BAA8B,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentsbank/sdk",
3
- "version": "1.0.10",
3
+ "version": "1.0.13",
4
4
  "description": "🔒 Secure Financial SDK for AgentsBank - Multi-chain wallet & transaction management. Requires explicit credentials and user authorization for financial operations.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,6 +9,12 @@
9
9
  "build": "tsc",
10
10
  "publish": "npm publish"
11
11
  },
12
+ "files": [
13
+ "dist",
14
+ "README.md",
15
+ "CHANGELOG.md",
16
+ "package.json"
17
+ ],
12
18
  "keywords": [
13
19
  "ai-agents",
14
20
  "blockchain",
package/.env DELETED
@@ -1,38 +0,0 @@
1
- # AgentsBank SDK - Environment Variables
2
- # SECURITY WARNING: Never commit .env to version control
3
-
4
- # ============================================
5
- # API Configuration (REQUIRED)
6
- # ============================================
7
- # Base URL of AgentsBank API
8
- AGENTSBANK_API_URL=https://api.agentsbank.online
9
-
10
- # ============================================
11
- # Authentication (Choose ONE method)
12
- # ============================================
13
-
14
- # METHOD 1: API Key (Recommended for production)
15
- AGENTSBANK_API_KEY=your-api-key-here-do-not-share
16
-
17
- # METHOD 2: Agent Credentials (For testing/setup)
18
- # Uncomment and fill only if using credential-based auth
19
- # AGENTSBANK_AGENT_USERNAME=agent_name
20
- # AGENTSBANK_AGENT_PASSWORD=agent_password_secret
21
-
22
- # ============================================
23
- # Optional: Pre-authenticated Token
24
- # ============================================
25
- # Only needed if you have a pre-issued JWT token
26
- # AGENTSBANK_AUTH_TOKEN=jwt-token-here
27
-
28
- # ============================================
29
- # Optional: Runtime Configuration
30
- # ============================================
31
- # Timeout for API requests (in milliseconds)
32
- SDK_REQUEST_TIMEOUT=10000
33
-
34
- # Enable verbose logging for debugging
35
- SDK_DEBUG=false
36
-
37
- # Custom audit logging endpoint (optional)
38
- # SDK_AUDIT_LOG_ENDPOINT=https://logs.example.com/audit
package/.env.example DELETED
@@ -1,53 +0,0 @@
1
- # AgentsBank SDK - Environment Variables Template
2
- # Copy this to .env and fill in your actual credentials
3
- # SECURITY WARNING: Never commit .env to version control
4
-
5
- # ============================================
6
- # API Configuration (REQUIRED)
7
- # ============================================
8
- # Base URL of AgentsBank API
9
- # For local development: http://localhost:3000
10
- # For production: https://api.agentsbank.online
11
- AGENTSBANK_API_URL=https://api.agentsbank.online
12
-
13
- # ============================================
14
- # Authentication (Choose ONE method)
15
- # ============================================
16
-
17
- # METHOD 1: API Key (Recommended for production)
18
- AGENTSBANK_API_KEY=your-api-key-here-do-not-share
19
-
20
- # METHOD 2: Agent Credentials (For testing/setup)
21
- # Uncomment and fill only if using credential-based auth
22
- # AGENTSBANK_AGENT_USERNAME=agent_name
23
- # AGENTSBANK_AGENT_PASSWORD=agent_password_secret
24
-
25
- # ============================================
26
- # Optional: Pre-authenticated Token
27
- # ============================================
28
- # Only needed if you have a pre-issued JWT token
29
- # AGENTSBANK_AUTH_TOKEN=jwt-token-here
30
-
31
- # ============================================
32
- # Optional: Runtime Configuration
33
- # ============================================
34
- # Environment: 'production' or 'sandbox'
35
- AGENTSBANK_ENVIRONMENT=production
36
-
37
- # Request timeout in milliseconds
38
- AGENTSBANK_TIMEOUT_MS=10000
39
-
40
- # Enable audit logging
41
- AGENTSBANK_AUDIT_LOG=true
42
-
43
- # Webhook URL for transaction notifications (optional)
44
- # AGENTSBANK_WEBHOOK_URL=https://your-domain.com/webhooks/agentsbank
45
-
46
- # ============================================
47
- # Security Checklist
48
- # ============================================
49
- # ✓ API key obtained from https://dashboard.agentsbank.ai
50
- # ✓ Never commit this file to git (add to .gitignore)
51
- # ✓ Rotate API key monthly or when team member leaves
52
- # ✓ Use different credentials for development vs production
53
- # ✓ Enable audit logging in production
package/SKILL.md DELETED
@@ -1,250 +0,0 @@
1
- # AgentsBank SDK - Financial Operations Skill
2
-
3
- **Status:** Production-grade, requires explicit user invocation for financial operations
4
- **Version:** 0.1.0
5
- **Risk Level:** High (financial transactions)
6
- **Autonomy:** ❌ Disabled for autonomous execution
7
-
8
- ---
9
-
10
- ## ⚠️ Security & Credential Requirements
11
-
12
- This is a **financial transaction SDK** that requires explicit credentials and user authorization. It is **NOT autonomously invocable** for security reasons.
13
-
14
- ### Required Environment Variables
15
-
16
- ```env
17
- # API Configuration (REQUIRED - NO DEFAULT)
18
- AGENTSBANK_API_URL=https://api.agentsbank.ai
19
-
20
- # Authentication (Choose ONE)
21
- AGENTSBANK_API_KEY=your-api-key-here
22
- # OR
23
- AGENTSBANK_AGENT_USERNAME=agent_name
24
- AGENTSBANK_AGENT_PASSWORD=agent_password_secret
25
-
26
- # Optional runtime token (if pre-authenticated)
27
- AGENTSBANK_AUTH_TOKEN=jwt-token-here
28
- ```
29
-
30
- - **`AGENTSBANK_API_URL`** (required): Base URL of the AgentsBank API endpoint
31
- - No defaults → must be explicitly set
32
- - Scope: API connectivity only
33
-
34
- - **`AGENTSBANK_API_KEY`** OR credentials (required for auth):
35
- - Primary authentication method
36
- - Scope: Wallet creation, transactions, balance queries
37
- - Must be rotated regularly
38
- - Cannot be embedded in code
39
-
40
- - **`AGENTSBANK_AUTH_TOKEN`** (optional): Pre-issued JWT token
41
- - Use if already authenticated
42
- - Shorter scope than API key
43
-
44
- ---
45
-
46
- ## 🔐 Credential Security Boundaries
47
-
48
- | Operation | Credential Required | Scope | Risk |
49
- |-----------|-------------------|-------|------|
50
- | Wallet Management | API Key + Agent Auth | Read/Write | 🔴 High |
51
- | Transactions | API Key + Agent Auth | Write only | 🔴 Critical |
52
- | Balance Query | API Key | Read only | 🟡 Medium |
53
- | Gas Estimation | API Key | Informational | 🟢 Low |
54
-
55
- ---
56
-
57
- ## 🚫 Autonomous Execution Policy
58
-
59
- **This SDK MUST NOT be autonomously invoked by AI agents.** Financial operations require:
60
-
61
- 1. **Explicit User Confirmation** – User must authorize before any transaction
62
- 2. **Human Review** – Transaction details must be reviewed and approved
63
- 3. **Audit Trail** – All operations logged with timestamp and actor
64
- 4. **Rate Limiting** – API enforces per-agent limits to prevent abuse
65
-
66
- ### Enforce Constraints in Code
67
-
68
- ```typescript
69
- // REQUIRED: Check for user authorization flag
70
- if (!context.userApproval) {
71
- throw new Error('Financial operations require explicit user authorization');
72
- }
73
-
74
- // REQUIRED: Log transaction intent before execution
75
- logger.info('User authorized transaction', {
76
- agentId: config.agentId,
77
- recipient: toAddress,
78
- amount: amount,
79
- timestamp: new Date()
80
- });
81
-
82
- // REQUIRED: Never retry failed financial operations without user re-approval
83
- ```
84
-
85
- ---
86
-
87
- ## 📦 Installation
88
-
89
- ```bash
90
- npm install @agentsbank/sdk
91
- ```
92
-
93
- ### Setup Steps
94
-
95
- 1. **Obtain Credentials**
96
- - Request API key from dashboard: https://dashboard.agentsbank.ai
97
- - OR set `AGENTSBANK_AGENT_USERNAME` + `AGENTSBANK_AGENT_PASSWORD`
98
- - Securely store credentials (never commit to git)
99
-
100
- 2. **Configure Environment**
101
- ```bash
102
- cp .env.example .env
103
- # Edit .env with your credentials
104
- ```
105
-
106
- 3. **Initialize SDK**
107
- ```typescript
108
- import { AgentsBankSDK } from '@agentsbank/sdk';
109
-
110
- const bank = new AgentsBankSDK({
111
- apiUrl: process.env.AGENTSBANK_API_URL,
112
- apiKey: process.env.AGENTSBANK_API_KEY,
113
- // OR credentials:
114
- agentUsername: process.env.AGENTSBANK_AGENT_USERNAME,
115
- agentPassword: process.env.AGENTSBANK_AGENT_PASSWORD,
116
- });
117
- ```
118
-
119
- ---
120
-
121
- ## 💰 Core Capabilities
122
-
123
- ### Wallet Management
124
- - **`createWallet(chain, type)`** – Create new multi-chain wallet
125
- - Chains: `ethereum`, `bsc`, `solana`
126
- - Types: `custodial`, `non-custodial`
127
- - ⚠️ Custodial wallets require setup confirmationSecurity
128
-
129
- - **`listWallets()`** – List all wallets for agent
130
- - **`getWallet(walletId)`** – Retrieve wallet details
131
- - **`getBalance(walletId)`** – Query wallet balance across assets
132
-
133
- ### Transaction Operations
134
- - **`sendTransaction(walletId, toAddress, amount, currency)`** – Execute transfer
135
- - **Requires:** Explicit user approval before execution
136
- - **Returns:** Transaction ID for tracking
137
- - **Timeout:** 300s default (configurable)
138
-
139
- - **`getTransaction(txId)`** – Retrieve transaction status
140
- - **`getTransactionHistory(walletId, limit)`** – List recent transactions
141
- - **`waitForConfirmation(txId)`** – Poll until confirmed or timeout
142
-
143
- ### Utilities
144
- - **`estimateGas(walletId, toAddress, amount)`** – Get gas cost estimate (informational only)
145
- - **`getStats(walletId, days)`** – Historical transaction metrics
146
- - **`refreshToken()`** – Renew JWT token before expiry
147
-
148
- ---
149
-
150
- ## 🔍 Audit & Compliance
151
-
152
- All financial operations trigger:
153
-
154
- - ✅ Agent authentication verification
155
- - ✅ Transaction signature & validation
156
- - ✅ Rate limit enforcement (per-agent per-minute)
157
- - ✅ Immutable audit log entry
158
- - ✅ Optional webhook notification to recipient
159
-
160
- ---
161
-
162
- ## ⚡ Quick Example
163
-
164
- ```typescript
165
- import { AgentsBankSDK } from '@agentsbank/sdk';
166
-
167
- // 1. Initialize with API Key
168
- const bank = new AgentsBankSDK({
169
- apiUrl: 'https://api.agentsbank.ai',
170
- apiKey: process.env.AGENTSBANK_API_KEY
171
- });
172
-
173
- // 2. Get or create wallet
174
- let wallet = await bank.listWallets().then(w => w[0]);
175
- if (!wallet) {
176
- wallet = await bank.createWallet('ethereum', 'non-custodial');
177
- }
178
-
179
- // 3. Check balance
180
- const balance = await bank.getBalance(wallet.wallet_id);
181
- console.log('Balance:', balance);
182
-
183
- // 4. ONLY with user approval:
184
- if (userConfirmsTransaction) {
185
- const tx = await bank.sendTransaction(
186
- wallet.wallet_id,
187
- '0xRecipient...',
188
- '1.5',
189
- 'ETH'
190
- );
191
- console.log('Tx ID:', tx.tx_id);
192
-
193
- // 5. Wait for confirmation
194
- const confirmed = await bank.waitForConfirmation(tx.tx_id);
195
- console.log('Status:', confirmed.status);
196
- }
197
- ```
198
-
199
- ---
200
-
201
- ## 🛑 Error Handling
202
-
203
- ```typescript
204
- try {
205
- await bank.sendTransaction(walletId, recipient, amount, currency);
206
- } catch (error) {
207
- if (error.message.includes('Invalid wallet')) {
208
- console.error('Wallet not found');
209
- } else if (error.message.includes('Insufficient balance')) {
210
- console.error('Not enough funds');
211
- } else if (error.message.includes('Rate limit exceeded')) {
212
- console.error('Too many requests - try again later');
213
- }
214
- }
215
- ```
216
-
217
- ---
218
-
219
- ## 🚀 Best Practices
220
-
221
- 1. **Never store credentials in code** – Use environment variables only
222
- 2. **Rotate API keys monthly** – Call `regenerateApiKey()` and update `.env`
223
- 3. **Validate recipient addresses** – Always verify before transaction
224
- 4. **Use non-custodial wallets** for agents when possible
225
- 5. **Monitor transaction history** – Regular audits via `getTransactionHistory()`
226
- 6. **Set low rate limits** – Start with 1-5 transactions/minute per agent
227
- 7. **Enable webhook notifications** – Get real-time transaction confirmations
228
-
229
- ---
230
-
231
- ## 📞 Support & Security Issues
232
-
233
- - Dashboard: https://dashboard.agentsbank.ai
234
- - Docs: https://docs.agentsbank.ai
235
- - Report security issues: security@agentsbank.ai (not public issues)
236
-
237
- ---
238
-
239
- ## 📋 Compliance Notes
240
-
241
- - **OAuth2 Support**: Via API Key or JWT bearer token
242
- - **Webhook Support**: Transaction confirmations, balance updates
243
- - **Sandbox Mode**: Available via `AGENTSBANK_ENVIRONMENT=sandbox` env var
244
- - **Audit Trail**: All transactions immutably logged with actor, timestamp, amount
245
- - **PCI DSS Notes**: Private keys never transmitted over network; stored encrypted at rest
246
-
247
- ---
248
-
249
- **Last Updated:** February 2026
250
- **Requires:** Node.js 18+, @agentsbank/sdk ^0.1.0