@zebec-network/exchange-card-sdk 1.1.0
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/LICENSE +21 -0
- package/README.md +339 -0
- package/dist/artifacts/abi/ERC20.json +350 -0
- package/dist/artifacts/abi/ZebecCard.json +1060 -0
- package/dist/artifacts/abi/index.d.ts +122 -0
- package/dist/artifacts/abi/index.js +10 -0
- package/dist/artifacts/index.d.ts +2 -0
- package/dist/artifacts/index.js +18 -0
- package/dist/artifacts/typechain-types/ERC20.d.ts +149 -0
- package/dist/artifacts/typechain-types/ERC20.js +2 -0
- package/dist/artifacts/typechain-types/ZebecCard.d.ts +639 -0
- package/dist/artifacts/typechain-types/ZebecCard.js +2 -0
- package/dist/artifacts/typechain-types/common.d.ts +50 -0
- package/dist/artifacts/typechain-types/common.js +2 -0
- package/dist/artifacts/typechain-types/factories/ERC20__factory.d.ts +280 -0
- package/dist/artifacts/typechain-types/factories/ERC20__factory.js +378 -0
- package/dist/artifacts/typechain-types/factories/ZebecCard__factory.d.ts +835 -0
- package/dist/artifacts/typechain-types/factories/ZebecCard__factory.js +1088 -0
- package/dist/artifacts/typechain-types/factories/index.d.ts +2 -0
- package/dist/artifacts/typechain-types/factories/index.js +10 -0
- package/dist/artifacts/typechain-types/index.d.ts +5 -0
- package/dist/artifacts/typechain-types/index.js +31 -0
- package/dist/chains.d.ts +18 -0
- package/dist/chains.js +39 -0
- package/dist/constants.d.ts +3649 -0
- package/dist/constants.js +2502 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.js +51 -0
- package/dist/helpers/apiHelpers.d.ts +30 -0
- package/dist/helpers/apiHelpers.js +92 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +26 -0
- package/dist/services/EvmService.d.ts +37 -0
- package/dist/services/EvmService.js +134 -0
- package/dist/services/TaoService.d.ts +49 -0
- package/dist/services/TaoService.js +106 -0
- package/dist/services/TonService.d.ts +57 -0
- package/dist/services/TonService.js +137 -0
- package/dist/services/XdbService.d.ts +58 -0
- package/dist/services/XdbService.js +140 -0
- package/dist/services/stellarService.d.ts +52 -0
- package/dist/services/stellarService.js +119 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.js +263 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +48 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Zebec Fintech Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# Zebec Card SDK
|
|
2
|
+
|
|
3
|
+
The Zebec Card SDK allows developers to integrate the functionality of purchasing and managing Zebec virtual cards into their applications. We currently support EVM chains (Ethereum, Binance Smart Chain (BSC), and Base) and Bittensor Network with the flexibility to toggle between mainnet and testnet environments based on configuration.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the Zebec Card SDK via npm:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i @zebec-fintech/silver-card-sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
To get started, create an instance of `ZebecCardService` for EVM compatible networks or `ZebecCardTAOService` for Bittensor Network. This instance requires a signer, a chain ID (for EVM only), and configuration details, including API credentials.
|
|
18
|
+
|
|
19
|
+
> **Note**: Testnets (e.g., Sepolia, BSC Testnet) can only be used if `sandbox` mode is enabled.
|
|
20
|
+
|
|
21
|
+
Example:
|
|
22
|
+
|
|
23
|
+
For EVM compatible networks:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { ethers } from 'ethers';
|
|
27
|
+
import { ZebecCardService, Recipient, CountryCode } from '@zebec-fintech/silver-card-sdk';
|
|
28
|
+
|
|
29
|
+
const signer: ethers.Signer = ... ; // Signer instance from Wallet Extension
|
|
30
|
+
|
|
31
|
+
const chainId = 11155111; // Sepolia testnet
|
|
32
|
+
const apiKey = process.env.API_KEY!;
|
|
33
|
+
const encryptionKey = process.env.ENCRYPTION_KEY!;
|
|
34
|
+
|
|
35
|
+
const service = new ZebecCardService(
|
|
36
|
+
signer,
|
|
37
|
+
chainId,
|
|
38
|
+
{
|
|
39
|
+
apiKey,
|
|
40
|
+
encryptionKey,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
sandbox: true, // Set to true for development or testing
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For Bittensor Network:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { ZebecCardTAOService } from '@zebec-fintech/silver-card-sdk';
|
|
52
|
+
|
|
53
|
+
const signer: <Keyring | Signer> = ... ; // Keyring or Signer instance from Wallet Extension
|
|
54
|
+
|
|
55
|
+
const service = new ZebecCardTAOService(
|
|
56
|
+
signer,
|
|
57
|
+
{
|
|
58
|
+
apiKey,
|
|
59
|
+
encryptionKey,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
sandbox: true, // Set to true for development or testing
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Fetch Quote
|
|
68
|
+
|
|
69
|
+
The `fetchQuote` method retrieves a quote for the specified amount in USD. The quote is used to calculate the corresponding token amount required for the card purchase. It expires in about 30 seconds.
|
|
70
|
+
|
|
71
|
+
Note: The `fetchQuote` method should be called regularly. Make sure to check it's validity before proceeding with the purchase.
|
|
72
|
+
|
|
73
|
+
#### Code Example
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const amount = "150.55"; // Amount in USD
|
|
77
|
+
const quote = await service.fetchQuote(amount);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Response
|
|
81
|
+
|
|
82
|
+
The `fetchQuote` method returns a quote object with the following fields:
|
|
83
|
+
|
|
84
|
+
- **id**: Unique quote identifier.
|
|
85
|
+
- **token**: Name or symbol of the token used to purchase the card. (e.g., `"USDC"`, `"TAO"`)
|
|
86
|
+
- **targetCurrency**: Currency code for the amount. (e.g., `"USD"`)
|
|
87
|
+
- **amountRequested**: Amount of USD the card is being purchased for.
|
|
88
|
+
- **pricePerUnitCurrency**: Price of the token per unit USD.
|
|
89
|
+
- **totalPrice**: Total token amount needed for purchase.
|
|
90
|
+
- **platformFee**: Any additional fees charged by the platform.
|
|
91
|
+
- **expiresIn**: Time in milliseconds before the quote expires.
|
|
92
|
+
- **timestamp**: Timestamp when the quote was generated.
|
|
93
|
+
- **status**: Quote status.
|
|
94
|
+
|
|
95
|
+
### Purchase Card
|
|
96
|
+
|
|
97
|
+
The `purchaseCard` method initiates a virtual card purchase. It performs four main operations:
|
|
98
|
+
|
|
99
|
+
1. Approves token spending to the ZebecCard smart contract. (ERC20 tokens only)
|
|
100
|
+
2. Deposits tokens into the user's Zebec vault.
|
|
101
|
+
3. Initiates the card purchase on-chain. (ERC20 tokens only)
|
|
102
|
+
4. Posts transaction data, along with metadata, to the Zebec backend.
|
|
103
|
+
|
|
104
|
+
The method returns a tuple with responses from each stage of the process.
|
|
105
|
+
|
|
106
|
+
#### Code Example
|
|
107
|
+
|
|
108
|
+
For EVM compatible networks:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
const participantId = "JohnChamling";
|
|
112
|
+
const firstName = "John";
|
|
113
|
+
const lastName = "Chamling";
|
|
114
|
+
const emailAddress = "user@example.com";
|
|
115
|
+
const mobilePhone = "+91 012345678";
|
|
116
|
+
const language = "en-US";
|
|
117
|
+
const city = "Bharatpur";
|
|
118
|
+
const state = "Bagmati";
|
|
119
|
+
const postalCode = "44200";
|
|
120
|
+
const countryCode: CountryCode = "NPL";
|
|
121
|
+
const address1 = "Shittal street, Bharatpur - 10, Chitwan";
|
|
122
|
+
|
|
123
|
+
const recipient = Recipient.create(
|
|
124
|
+
participantId,
|
|
125
|
+
firstName,
|
|
126
|
+
lastName,
|
|
127
|
+
emailAddress,
|
|
128
|
+
mobilePhone,
|
|
129
|
+
language,
|
|
130
|
+
city,
|
|
131
|
+
state,
|
|
132
|
+
postalCode,
|
|
133
|
+
countryCode,
|
|
134
|
+
address1,
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const amount = "150.55";
|
|
138
|
+
const quote = await service.fetchQuote(amount);
|
|
139
|
+
const [depositResponse, buyCardResponse, apiResponse] = await service.purchaseCard({
|
|
140
|
+
amount,
|
|
141
|
+
recipient,
|
|
142
|
+
quote,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
console.log("Deposit Transaction Hash:", depositResponse.hash);
|
|
146
|
+
console.log("Purchase Transaction Hash:", buyCardResponse.hash);
|
|
147
|
+
console.log("Zebec Server Response:", apiResponse.data);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
For Bittensor Network:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const participantId = "JohnChamling";
|
|
154
|
+
const firstName = "John";
|
|
155
|
+
const lastName = "Chamling";
|
|
156
|
+
const emailAddress = "user@example.com";
|
|
157
|
+
const mobilePhone = "+91 012345678";
|
|
158
|
+
const language = "en-US";
|
|
159
|
+
const city = "Bharatpur";
|
|
160
|
+
const state = "Bagmati";
|
|
161
|
+
const postalCode = "44200";
|
|
162
|
+
const countryCode: CountryCode = "NPL";
|
|
163
|
+
const address1 = "Shittal street, Bharatpur - 10, Chitwan";
|
|
164
|
+
|
|
165
|
+
const recipient = Recipient.create(
|
|
166
|
+
participantId,
|
|
167
|
+
firstName,
|
|
168
|
+
lastName,
|
|
169
|
+
emailAddress,
|
|
170
|
+
mobilePhone,
|
|
171
|
+
language,
|
|
172
|
+
city,
|
|
173
|
+
state,
|
|
174
|
+
postalCode,
|
|
175
|
+
countryCode,
|
|
176
|
+
address1,
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
const amount = "150.55"; // Amount in USD
|
|
180
|
+
const quote = await service.fetchQuote(amount);
|
|
181
|
+
const [depositResponse, apiResponse] = await service.purchaseCard({
|
|
182
|
+
walletAddress: signer.address || "<wallet_address>",
|
|
183
|
+
amount,
|
|
184
|
+
recipient,
|
|
185
|
+
quote,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
console.log(
|
|
189
|
+
`Deposit response: \n BlockHash: ${depositResponse.blockHash} \n TransactionHash: ${depositResponse.txHash}`,
|
|
190
|
+
);
|
|
191
|
+
console.log("Zebec Server Response:", apiResponse.data);
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Configuration Parameters
|
|
197
|
+
|
|
198
|
+
### ZebecCardService
|
|
199
|
+
|
|
200
|
+
To create an instance of `ZebecCardService`, you need:
|
|
201
|
+
|
|
202
|
+
- **signer**: An instance of `ethers.Signer`.
|
|
203
|
+
- **chainId**: The ID of the blockchain (see list of supported chains below).
|
|
204
|
+
- **apiConfig**: Object containing `apiKey` and `encryptionKey`.
|
|
205
|
+
- **sdkConfig (optional)**: SDK-specific settings, such as:
|
|
206
|
+
- `sandbox`: Boolean, set to `true` for testnets.
|
|
207
|
+
|
|
208
|
+
### ZebecCardTAOService
|
|
209
|
+
|
|
210
|
+
To create an instance of `ZebecCardTAOService`, you need:
|
|
211
|
+
|
|
212
|
+
- **signer**: An instance of `Keyring` or `Signer`.
|
|
213
|
+
- **apiConfig**: Object containing `apiKey` and `encryptionKey`.
|
|
214
|
+
- **sdkConfig (optional)**: SDK-specific settings, such as:
|
|
215
|
+
- `sandbox`: Boolean, set to `true` for testnets.
|
|
216
|
+
|
|
217
|
+
### EVM Supported Chains
|
|
218
|
+
|
|
219
|
+
| Chain | Chain ID |
|
|
220
|
+
| ------------------- | ------------------------------- |
|
|
221
|
+
| Ethereum | Mainnet (1), Sepolia (11155111) |
|
|
222
|
+
| Binance Smart Chain | Mainnet (56), Testnet (97) |
|
|
223
|
+
| Base | Mainnet (8453) |
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Recipient Fields
|
|
228
|
+
|
|
229
|
+
To create a valid `Recipient` instance, provide the following details:
|
|
230
|
+
|
|
231
|
+
- **participantId** (alphanumeric string): Unique identifier for the buyer end user. 1-20 chars.
|
|
232
|
+
- **firstName**, **lastName** (string): Participant's full name.
|
|
233
|
+
- **emailAddress** (string): Contact email. 1-80 chars
|
|
234
|
+
- **mobilePhone** (string): Mobile number with country code.
|
|
235
|
+
- **language** (string): Language code (e.g., `"en-US"`).
|
|
236
|
+
- **city**, **state**, **postalCode** (string): Location details.
|
|
237
|
+
- **countryCode** (CountryCode enum): ISO 3166-1 alpha-3 country code.
|
|
238
|
+
- **address1** (string): Street address. (max 50 chars)
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Responses
|
|
243
|
+
|
|
244
|
+
The `purchaseCard` method returns three responses:
|
|
245
|
+
|
|
246
|
+
1. **depositResponse**: Transaction response for token deposit.
|
|
247
|
+
2. **buyCardResponse**: Transaction response for card purchase. (EVM only)
|
|
248
|
+
3. **apiResponse**: API response from Zebec's backend with additional transaction metadata.
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Environment Variables
|
|
253
|
+
|
|
254
|
+
- **API_KEY**: Your Zebec API Key.
|
|
255
|
+
- **ENCRYPTION_KEY**: Your Zebec encryption key for secure data handling.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Supported Countries
|
|
260
|
+
|
|
261
|
+
| Country | Code |
|
|
262
|
+
| -------------------------------- | ---- |
|
|
263
|
+
| Algeria | DZA |
|
|
264
|
+
| Angola | AGO |
|
|
265
|
+
| Argentina | ARG |
|
|
266
|
+
| Australia | AUS |
|
|
267
|
+
| Austria | AUT |
|
|
268
|
+
| Belgium | BEL |
|
|
269
|
+
| Bolivia (Plurinational State of) | BOL |
|
|
270
|
+
| Brazil | BRA |
|
|
271
|
+
| Cameroon | CMR |
|
|
272
|
+
| Canada | CAN |
|
|
273
|
+
| Chile | CHL |
|
|
274
|
+
| Costa Rica | CRI |
|
|
275
|
+
| Cyprus | CYP |
|
|
276
|
+
| Czechia | CZE |
|
|
277
|
+
| Denmark | DNK |
|
|
278
|
+
| Ecuador | ECU |
|
|
279
|
+
| Egypt | EGY |
|
|
280
|
+
| El Salvador | SLV |
|
|
281
|
+
| Estonia | EST |
|
|
282
|
+
| Finland | FIN |
|
|
283
|
+
| France | FRA |
|
|
284
|
+
| Georgia | GEO |
|
|
285
|
+
| Germany | DEU |
|
|
286
|
+
| Ghana | GHA |
|
|
287
|
+
| Greece | GRC |
|
|
288
|
+
| Guatemala | GTM |
|
|
289
|
+
| Honduras | HND |
|
|
290
|
+
| Hungary | HUN |
|
|
291
|
+
| Iceland | ISL |
|
|
292
|
+
| Ireland | IRL |
|
|
293
|
+
| Italy | ITA |
|
|
294
|
+
| Jamaica | JAM |
|
|
295
|
+
| Japan | JPN |
|
|
296
|
+
| Jordan | JOR |
|
|
297
|
+
| Kenya | KEN |
|
|
298
|
+
| Korea, Republic of Korea | KOR |
|
|
299
|
+
| Kuwait | KWT |
|
|
300
|
+
| Lithuania | LTU |
|
|
301
|
+
| Luxembourg | LUX |
|
|
302
|
+
| Malawi | MWI |
|
|
303
|
+
| Malaysia | MYS |
|
|
304
|
+
| Malta | MLT |
|
|
305
|
+
| Mexico | MEX |
|
|
306
|
+
| Morocco | MAR |
|
|
307
|
+
| Mozambique | MOZ |
|
|
308
|
+
| Nepal | NPL |
|
|
309
|
+
| Netherlands | NLD |
|
|
310
|
+
| New Zealand | NZL |
|
|
311
|
+
| Nigeria | NGA |
|
|
312
|
+
| Norway | NOR |
|
|
313
|
+
| Oman | OMN |
|
|
314
|
+
| Pakistan | PAK |
|
|
315
|
+
| Papua New Guinea | PNG |
|
|
316
|
+
| Paraguay | PRY |
|
|
317
|
+
| Peru | PER |
|
|
318
|
+
| Philippines | PHL |
|
|
319
|
+
| Poland | POL |
|
|
320
|
+
| Portugal | PRT |
|
|
321
|
+
| Puerto Rico | PRI |
|
|
322
|
+
| Qatar | QAT |
|
|
323
|
+
| Romania | ROU |
|
|
324
|
+
| Saudi Arabia | SAU |
|
|
325
|
+
| Singapore | SGP |
|
|
326
|
+
| Slovakia | SVK |
|
|
327
|
+
| Slovenia | SVN |
|
|
328
|
+
| Spain | ESP |
|
|
329
|
+
| Sweden | SWE |
|
|
330
|
+
| Taiwan | TWN |
|
|
331
|
+
| Thailand | THA |
|
|
332
|
+
| Trinidad and Tobago | TTO |
|
|
333
|
+
| Tunisia | TUN |
|
|
334
|
+
| Turkey | TUR |
|
|
335
|
+
| United Kingdom | GBR |
|
|
336
|
+
| United States | USA |
|
|
337
|
+
| Uruguay | URY |
|
|
338
|
+
| Vanuatu | VUT |
|
|
339
|
+
| Zambia | ZMB |
|