Signup
Search…
Requesting SLP Balances
experimental (not available in production yet)

Introduction

In Bitcoin Cash SLP tokens are categorized in two groups of fungible and non-fungible tokens....Using Signup you can request for the overall SLP balances a user has. The request should be accepted by the user to allow your application to access the data.

How to use

1
signup.requestAccess(["slp_address", "slp_balances"])
2
.then(({slpAddr, slpBalances}) => {
3
// User approved!
4
console.log(slpAddr, slpBalances);
5
});
Copied!
This command will return the SLP address of the user and their SLP balances to your application. You can use user's SLP address to identify or login the user or send tokens to them. This promise will return the slpAddr and slpBalances similar to this payload:
1
{
2
slpAddr: String<slp address>,
3
slpBalances: [{
4
tokenId: String<txid>,
5
ticker: String,
6
name: String,
7
value: Number,
8
decimals: Number,
9
documentUri: String,
10
type: String<"Token", "NFT-Child", "NFT-Group">,
11
nftParentId: String<txid>, // will be available only for NFT-Child type
12
}]
13
}
Copied!
You can use Signup's utility functions to process these data for easier consumption. For example you can only get the fungible tokens like:
1
const { onlyTokens } = signup.utility;
2
const tokens = onlyTokens(slpBalances);
Copied!
Or similarly onlye NFT children:
1
const { onlyChildNFTs } = signup.utility;
2
const nfts = onlyChildNFTs(slpBalances);
Copied!
You can also get the list of NFTs categorized under their Group:
1
const { NFTsByGroup } = signup.utility;
2
const nfts = NFTsByGroup(slpBalances);
3
4
console.log(nfts);
5
// [{
6
// groupName: String,
7
// groupId: String,
8
// documentUri: String,
9
// initialQuantity: Number,
10
// batonExist: Boolean,
11
// tokens: [{
12
// tokenId: String<txid>,
13
// ticker: String,
14
// name: String,
15
// value: Number,
16
// decimals: Number,
17
// documentUri: String,
18
// }]
19
// }]
20
Copied!
Last modified 8mo ago
Copy link