stxer 0.3.1 → 0.3.2
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 +93 -4
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,9 +1,98 @@
|
|
|
1
|
-
stxer SDK
|
|
2
|
-
----
|
|
1
|
+
# stxer SDK
|
|
3
2
|
|
|
3
|
+
A powerful SDK for Stacks blockchain that provides batch operations and transaction simulation capabilities.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
+
```bash
|
|
8
|
+
npm install stxer
|
|
9
|
+
# or
|
|
10
|
+
yarn add stxer
|
|
7
11
|
```
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
### 1. Batch Operations
|
|
16
|
+
|
|
17
|
+
The SDK provides efficient batch reading capabilities for Stacks blockchain:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { batchRead, batchReadonly } from 'stxer';
|
|
21
|
+
|
|
22
|
+
// Batch read variables and maps
|
|
23
|
+
const result = await batchRead({
|
|
24
|
+
variables: [{
|
|
25
|
+
contract: contractPrincipalCV(...),
|
|
26
|
+
variableName: 'my-var'
|
|
27
|
+
}],
|
|
28
|
+
maps: [{
|
|
29
|
+
contract: contractPrincipalCV(...),
|
|
30
|
+
mapName: 'my-map',
|
|
31
|
+
mapKey: someCV
|
|
32
|
+
}]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Batch readonly function calls
|
|
36
|
+
const readonlyResult = await batchReadonly({
|
|
37
|
+
readonly: [{
|
|
38
|
+
contract: contractPrincipalCV(...),
|
|
39
|
+
functionName: 'my-function',
|
|
40
|
+
functionArgs: [/* clarity values */]
|
|
41
|
+
}]
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Transaction Simulation
|
|
46
|
+
|
|
47
|
+
Simulate complex transaction sequences before executing them on-chain:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { SimulationBuilder } from 'stxer';
|
|
51
|
+
|
|
52
|
+
const simulationId = await SimulationBuilder.new({
|
|
53
|
+
network: 'mainnet', // or 'testnet'
|
|
54
|
+
})
|
|
55
|
+
.withSender('ST...') // Set default sender
|
|
56
|
+
.addContractCall({
|
|
57
|
+
contract_id: 'ST...contract-name',
|
|
58
|
+
function_name: 'my-function',
|
|
59
|
+
function_args: [/* clarity values */]
|
|
60
|
+
})
|
|
61
|
+
.addSTXTransfer({
|
|
62
|
+
recipient: 'ST...',
|
|
63
|
+
amount: 1000000 // in microSTX
|
|
64
|
+
})
|
|
65
|
+
.addContractDeploy({
|
|
66
|
+
contract_name: 'my-contract',
|
|
67
|
+
source_code: '(define-public (hello) (ok "world"))'
|
|
68
|
+
})
|
|
69
|
+
.run();
|
|
70
|
+
|
|
71
|
+
// View simulation results at: https://stxer.xyz/simulations/{network}/{simulationId}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
You can customize the API endpoints:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const builder = SimulationBuilder.new({
|
|
80
|
+
apiEndpoint: 'https://api.stxer.xyz', // Default stxer API endpoint
|
|
81
|
+
stacksNodeAPI: 'https://api.hiro.so', // Default Stacks API endpoint
|
|
82
|
+
network: 'mainnet' // or 'testnet'
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Support
|
|
87
|
+
|
|
88
|
+
This product is made possible through community support. Consider supporting the development:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
SP212Y5JKN59YP3GYG07K3S8W5SSGE4KH6B5STXER
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
For feedback and feature requests, contact: contact@stxer.xyz
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stxer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Kyle Fang",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/stxer/stxer-sdk"
|
|
9
|
+
},
|
|
6
10
|
"main": "dist/index.js",
|
|
7
11
|
"module": "dist/stxer.esm.js",
|
|
8
12
|
"typings": "dist/index.d.ts",
|