@armory-sh/base 0.2.23 → 0.2.24
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.
- package/README.md +155 -12
- package/package.json +17 -1
package/README.md
CHANGED
|
@@ -1,28 +1,171 @@
|
|
|
1
1
|
# @armory-sh/base
|
|
2
2
|
|
|
3
|
-
Core types and
|
|
3
|
+
Armory x402 SDK — Core protocol types, EIP-712 signing, encoding, network configs, and token registry. 100% compatible with Coinbase x402 SDKs.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[Documentation](https://armory.sh) | [License](LICENSE)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
10
|
bun add @armory-sh/base
|
|
9
11
|
```
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Why Armory?
|
|
14
|
+
|
|
15
|
+
Armory enables HTTP API payments via EIP-3009 `transferWithAuthorization`. Let your users pay with USDC directly from their wallet—no credit cards, no middlemen, no gas for payers.
|
|
16
|
+
|
|
17
|
+
## Key Exports
|
|
12
18
|
|
|
13
19
|
```typescript
|
|
14
|
-
import
|
|
15
|
-
|
|
20
|
+
import {
|
|
21
|
+
// Types
|
|
22
|
+
type PaymentPayload,
|
|
23
|
+
type PaymentPayloadV2,
|
|
24
|
+
type PaymentRequirementsV2,
|
|
25
|
+
type SettlementResponseV2,
|
|
26
|
+
type CustomToken,
|
|
27
|
+
type NetworkConfig,
|
|
28
|
+
|
|
29
|
+
// Encoding/Decoding
|
|
30
|
+
encodePaymentV2,
|
|
31
|
+
decodePaymentV2,
|
|
32
|
+
encodeSettlementV2,
|
|
33
|
+
decodeSettlementV2,
|
|
34
|
+
safeBase64Encode,
|
|
35
|
+
safeBase64Decode,
|
|
36
|
+
|
|
37
|
+
// EIP-712
|
|
38
|
+
createEIP712Domain,
|
|
39
|
+
createTransferWithAuthorization,
|
|
40
|
+
validateTransferWithAuthorization,
|
|
41
|
+
EIP712_TYPES,
|
|
42
|
+
|
|
43
|
+
// Networks
|
|
44
|
+
NETWORKS,
|
|
45
|
+
getNetworkConfig,
|
|
46
|
+
getNetworkByChainId,
|
|
47
|
+
getMainnets,
|
|
48
|
+
getTestnets,
|
|
49
|
+
|
|
50
|
+
// Token Registry
|
|
51
|
+
TOKENS,
|
|
52
|
+
registerToken,
|
|
53
|
+
getCustomToken,
|
|
54
|
+
getAllCustomTokens,
|
|
55
|
+
unregisterToken,
|
|
56
|
+
isCustomToken,
|
|
57
|
+
|
|
58
|
+
// Utilities
|
|
59
|
+
createNonce,
|
|
60
|
+
toAtomicUnits,
|
|
61
|
+
fromAtomicUnits,
|
|
62
|
+
resolveNetwork,
|
|
63
|
+
resolveToken,
|
|
64
|
+
} from '@armory-sh/base';
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
### Pre-configured Tokens
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { TOKENS } from '@armory-sh/base'
|
|
73
|
+
|
|
74
|
+
const usdc = TOKENS.USDC_BASE
|
|
75
|
+
console.log(usdc)
|
|
76
|
+
// {
|
|
77
|
+
// symbol: 'USDC',
|
|
78
|
+
// name: 'USD Coin',
|
|
79
|
+
// contractAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
80
|
+
// chainId: 8453,
|
|
81
|
+
// decimals: 6
|
|
82
|
+
// }
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Create EIP-712 Domain
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { createEIP712Domain } from '@armory-sh/base'
|
|
89
|
+
|
|
90
|
+
const domain = createEIP712Domain({
|
|
91
|
+
verifyingContract: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
92
|
+
chainId: 8453
|
|
93
|
+
})
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Generate Nonce
|
|
16
97
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
98
|
+
```typescript
|
|
99
|
+
import { createNonce } from '@armory-sh/base'
|
|
100
|
+
|
|
101
|
+
const nonce = createNonce()
|
|
102
|
+
// '0x0000000000000000000000000000000000000000000000000000000000000001'
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Register Custom Token
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { registerToken, type CustomToken } from '@armory-sh/base'
|
|
109
|
+
|
|
110
|
+
const myToken: CustomToken = {
|
|
111
|
+
symbol: 'MYTOKEN',
|
|
112
|
+
name: 'My Custom Token',
|
|
113
|
+
version: '1',
|
|
114
|
+
contractAddress: '0x...',
|
|
115
|
+
chainId: 8453,
|
|
116
|
+
decimals: 18,
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
registerToken(myToken)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Encode/Decode Payment
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { encodePaymentV2, decodePaymentV2 } from '@armory-sh/base'
|
|
126
|
+
|
|
127
|
+
const payload = {
|
|
21
128
|
chainId: 'eip155:8453',
|
|
22
|
-
assetId: 'eip155:8453/erc20:
|
|
129
|
+
assetId: 'eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
130
|
+
payTo: '0x...',
|
|
131
|
+
signature: {
|
|
132
|
+
from: '0x...',
|
|
133
|
+
to: '0x...',
|
|
134
|
+
value: '1000000',
|
|
135
|
+
validAfter: '0',
|
|
136
|
+
validBefore: '1736899200',
|
|
137
|
+
nonce: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
138
|
+
signature: { r: '0x...', s: '0x...', v: 28 }
|
|
139
|
+
}
|
|
23
140
|
}
|
|
141
|
+
|
|
142
|
+
// Encode for HTTP header
|
|
143
|
+
const encoded = encodePaymentV2(payload)
|
|
144
|
+
|
|
145
|
+
// Decode from HTTP header
|
|
146
|
+
const decoded = decodePaymentV2(encoded)
|
|
24
147
|
```
|
|
25
148
|
|
|
26
|
-
|
|
149
|
+
## Features
|
|
150
|
+
|
|
151
|
+
- **x402 v2 Protocol**: Full compatibility with Coinbase x402 SDKs
|
|
152
|
+
- **EIP-3009 / EIP-712**: Typed data signing for secure off-chain payments
|
|
153
|
+
- **Network Registry**: Ethereum, Base, SKALE — mainnets and testnets
|
|
154
|
+
- **Token Registry**: USDC, EURC, USDT, WBTC, WETH, SKL
|
|
155
|
+
- **Custom Tokens**: Register your own tokens
|
|
156
|
+
- **Encoding**: Base64URL encoding for HTTP headers
|
|
157
|
+
|
|
158
|
+
## Supported Networks
|
|
159
|
+
|
|
160
|
+
| Network | Chain ID |
|
|
161
|
+
|---------|----------|
|
|
162
|
+
| Ethereum | 1 |
|
|
163
|
+
| Base | 8453 |
|
|
164
|
+
| Base Sepolia | 84532 |
|
|
165
|
+
| SKALE Base | 1187947933 |
|
|
166
|
+
| SKALE Base Sepolia | 324705682 |
|
|
167
|
+
| Ethereum Sepolia | 11155111 |
|
|
168
|
+
|
|
169
|
+
## License
|
|
27
170
|
|
|
28
|
-
MIT
|
|
171
|
+
MIT © [Sawyer Cutler](https://github.com/TheGreatAxios/armory)
|
package/package.json
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@armory-sh/base",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.24",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Sawyer Cutler <sawyer@dirtroad.dev>",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"x402",
|
|
8
|
+
"ai",
|
|
9
|
+
"agentic commerce",
|
|
10
|
+
"ai agent",
|
|
11
|
+
"stablecoins",
|
|
12
|
+
"eip-3009",
|
|
13
|
+
"skale",
|
|
14
|
+
"base",
|
|
15
|
+
"machine economy",
|
|
16
|
+
"payment",
|
|
17
|
+
"crypto",
|
|
18
|
+
"web3",
|
|
19
|
+
"ethereum",
|
|
20
|
+
"usdc"
|
|
21
|
+
],
|
|
6
22
|
"type": "module",
|
|
7
23
|
"main": "./dist/index.js",
|
|
8
24
|
"types": "./dist/index.d.ts",
|