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

Commit 6b33893

Browse files
committed
Added documentation for tokenUtxoDetails()
1 parent a90dfd4 commit 6b33893

1 file changed

Lines changed: 79 additions & 2 deletions

File tree

src/data/docs/slp/js/util.md

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,13 @@ If false, the UTXO is safe for a wallet to spend in a normal BCH transaction.
679679

680680
(async () => {
681681
try {
682-
const u = await SLP.Address.utxo("bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90")
682+
const u = await SLP.Address.utxo("bitcoincash:qpcqs0n5xap26un2828n55gan2ylj7wavvzeuwdx05")
683683
const utxos = u.utxos
684684

685685
console.log(`utxos: ${JSON.stringify(utxos,null,2)}`)
686686

687687
const isSLPUtxo: await SLP.Utils.isTokenUtxo(utxos)
688-
console.log(`canSpend: ${JSON.stringify(canSpend,null,2}`)
688+
console.log(`isSLPUtxo: ${JSON.stringify(canSpend,null,2}`)
689689
} catch (error) {
690690
console.error(error)
691691
}
@@ -719,6 +719,83 @@ If false, the UTXO is safe for a wallet to spend in a normal BCH transaction.
719719
true
720720
]
721721

722+
### `tokenUtxoDetails`
723+
724+
Hydrate a UTXO with SLP token metadata.
725+
726+
Expects an array of UTXO objects as input. Returns an array of equal size.
727+
If the UTXO does not belong to a SLP transaction, it will return false.
728+
If the UTXO is part of an SLP transaction, it will return the UTXO object
729+
with additional SLP information attached.
730+
731+
#### Arguments
732+
733+
1. utxos: `Array` of utxo objects **required**.
734+
735+
#### Result
736+
737+
- `Array`
738+
- `false`: The UTXO does not belong to an SLP token and is safe to spend.
739+
- `Object`: The same UTXO object hydrated with SLP token metadata.
740+
741+
#### Examples
742+
743+
(async () => {
744+
try {
745+
const u = await SLP.Address.utxo("bitcoincash:qpcqs0n5xap26un2828n55gan2ylj7wavvzeuwdx05")
746+
const utxos = u.utxos
747+
748+
console.log(`utxos: ${JSON.stringify(utxos,null,2)}`)
749+
750+
const isSLPUtxo: await SLP.Utils.tokenUtxoDetails(utxos)
751+
console.log(`isSLPUtxo: ${JSON.stringify(canSpend,null,2}`)
752+
} catch (error) {
753+
console.error(error)
754+
}
755+
})()
756+
757+
// returns
758+
utxos: [
759+
{
760+
txid:
761+
"bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90",
762+
vout: 3,
763+
amount: 0.00002015,
764+
satoshis: 2015,
765+
height: 594892,
766+
confirmations: 5
767+
},
768+
{
769+
txid:
770+
"bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90",
771+
vout: 2,
772+
amount: 0.00000546,
773+
satoshis: 546,
774+
height: 594892,
775+
confirmations: 5
776+
}
777+
]
778+
779+
isSLPUtxo:
780+
[
781+
false,
782+
{
783+
"txid": "bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90",
784+
"vout": 2,
785+
"amount": 0.00000546,
786+
"satoshis": 546,
787+
"height": 594892,
788+
"confirmations": 5,
789+
"tokenType": "minting-baton",
790+
"tokenId": "bd158c564dd4ef54305b14f44f8e94c44b649f246dab14bcb42fb0d0078b8a90",
791+
"tokenTicker": "SLPSDK",
792+
"tokenName": "SLP SDK example using BITBOX",
793+
"tokenDocumentUrl": "developer.bitcoin.com",
794+
"tokenDocumentHash": "",
795+
"decimals": 8
796+
}
797+
]
798+
722799
### `burnTotal`
723800

724801
List input, output and burn total for slp transaction

0 commit comments

Comments
 (0)