Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit b450a70

Browse files
authored
Merge pull request #158 from Bitcoin-com/slp-docs
Slp docs
2 parents 022b43f + 88d8df1 commit b450a70

1 file changed

Lines changed: 64 additions & 10 deletions

File tree

src/data/docs/slp/utils.md

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,22 @@ balances : `Object`. The address's balances
9292
})();
9393

9494
// returns
95-
// { '968ff0cc4c93864001e03e9524e351250b94ec56150fa4897f65b0b6477d44d4': '9980',
96-
// df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb: '617',
97-
// b96304d12f1bbc2196df582516410e55a9b34e13c7b4585bf5c1770af30d034f: '1',
98-
// a436c8e1b6bee3d701c6044d190f76f774be83c36de8d34a988af4489e86dd37: '776'
99-
// }
95+
// [ { tokenId:
96+
// '968ff0cc4c93864001e03e9524e351250b94ec56150fa4897f65b0b6477d44d4',
97+
// balance: '9980',
98+
// decimalCount: 9 },
99+
// { tokenId:
100+
// 'df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb',
101+
// balance: '617',
102+
// decimalCount: 8 },
103+
// { tokenId:
104+
// 'b96304d12f1bbc2196df582516410e55a9b34e13c7b4585bf5c1770af30d034f',
105+
// balance: '1',
106+
// decimalCount: 0 },
107+
// { tokenId:
108+
// 'a436c8e1b6bee3d701c6044d190f76f774be83c36de8d34a988af4489e86dd37',
109+
// balance: '776',
110+
// decimalCount: 7 } ]
100111

101112
// balances for Cash Address
102113
(async () => {
@@ -109,7 +120,10 @@ balances : `Object`. The address's balances
109120
})();
110121

111122
// returns
112-
// { '467969e067f5612863d0bf2daaa70dede2c6be03abb6fd401c5ef6e1e1f1f5c5': '507' }
123+
// [ { tokenId:
124+
// '467969e067f5612863d0bf2daaa70dede2c6be03abb6fd401c5ef6e1e1f1f5c5',
125+
// balance: '507',
126+
// decimalCount: 2 } ]
113127

114128
// balances for Legacy Address
115129
(async () => {
@@ -122,7 +136,10 @@ balances : `Object`. The address's balances
122136
})();
123137

124138
// returns
125-
// { '467969e067f5612863d0bf2daaa70dede2c6be03abb6fd401c5ef6e1e1f1f5c5': '507' }
139+
// [ { tokenId:
140+
// '467969e067f5612863d0bf2daaa70dede2c6be03abb6fd401c5ef6e1e1f1f5c5',
141+
// balance: '507',
142+
// decimalCount: 2 } ]
126143

127144
### `balance`
128145

@@ -153,7 +170,10 @@ balance : `Object`. the address's balance for single token
153170
})();
154171

155172
// returns
156-
// 617
173+
// { tokenId:
174+
// 'df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb',
175+
// balance: '617',
176+
// decimalCount: 8 }
157177

158178
// single balance for Cash Address
159179
(async () => {
@@ -169,7 +189,10 @@ balance : `Object`. the address's balance for single token
169189
})();
170190

171191
// returns
172-
// 617
192+
// { tokenId:
193+
// 'df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb',
194+
// balance: '617',
195+
// decimalCount: 8 }
173196

174197
// single balance for Legacy Address
175198
(async () => {
@@ -185,7 +208,10 @@ balance : `Object`. the address's balance for single token
185208
})();
186209

187210
// returns
188-
// 1234
211+
// { tokenId:
212+
// '467969e067f5612863d0bf2daaa70dede2c6be03abb6fd401c5ef6e1e1f1f5c5',
213+
// balance: '1234',
214+
// decimalCount: 2 }
189215

190216
### `validateTxid`
191217

@@ -195,6 +221,7 @@ Validate that txid is an SLP transaction
195221

196222
1. txid : `String` required. The transaction id to validate
197223
2. network : `String` required. mainnet or testnet
224+
3. getRawTransactions: `Function` optional.
198225

199226
#### Result
200227

@@ -217,3 +244,30 @@ isValid : `Boolean`
217244

218245
// returns
219246
true
247+
248+
### `createValidator`
249+
250+
Create and return a local validator
251+
252+
#### Arguments
253+
254+
1. network : `String` required. mainnet or testnet
255+
2. getRawTransactions: `Function` optional.
256+
257+
#### Result
258+
259+
slpValidator : `slpValidator`
260+
261+
#### Examples
262+
263+
// validate SLP txid
264+
(async () => {
265+
try {
266+
let slpValidator = await SLP.Utils.createValidator(
267+
"mainnet"
268+
);
269+
console.log(slpValidator);
270+
} catch (error) {
271+
console.error(error);
272+
}
273+
})();

0 commit comments

Comments
 (0)