Obtenga la lista de restricciones globales de tokens.
Guía restricting tokens transfers completa.
// replace with token id
const tokenIdHex = '634a8ac3fc2b65b3';
const tokenId = new TokenId(tokenIdHex);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const restrictionHttp = repositoryFactory.createRestrictionTokenRepository();
const criteria = { tokenId };
restrictionHttp.search(criteria).subscribe(
(tokenGlobalRestrictions) => {
if (tokenGlobalRestrictions.data.length > 0) {
console.log(
'Key\t',
'Reference TokenId\t',
'Restriction Type\t',
'Restriction Value',
);
tokenGlobalRestrictions.data.forEach((tokenRestriction) => {
if (tokenRestriction instanceof TokenGlobalRestriction) {
tokenRestriction.restrictions.forEach(
(value: TokenGlobalRestrictionItem) => {
console.log(
'\n',
value.key,
value.referenceTokenId.toHex(),
TokenRestrictionType[value.restrictionType],
value.restrictionValue,
);
},
);
}
});
} else {
console.log(
'\n The token does not have token global restrictions assigned.',
);
}
},
(err) => console.log(err),
);
// replace with token id
const tokenIdHex = '634a8ac3fc2b65b3';
const tokenId = new bitxor_sdk_1.TokenId(tokenIdHex);
// replace with node endpoint
const nodeUrl = 'NODE_URL';
const repositoryFactory = new bitxor_sdk_1.RepositoryFactoryHttp(nodeUrl);
const restrictionHttp = repositoryFactory.createRestrictionTokenRepository();
const criteria = { tokenId };
restrictionHttp.search(criteria).subscribe(
(tokenGlobalRestrictions) => {
if (tokenGlobalRestrictions.data.length > 0) {
console.log(
'Key\t',
'Reference TokenId\t',
'Restriction Type\t',
'Restriction Value',
);
tokenGlobalRestrictions.data.forEach((tokenRestriction) => {
if (tokenRestriction instanceof bitxor_sdk_1.TokenGlobalRestriction) {
tokenRestriction.restrictions.forEach((value) => {
console.log(
'\n',
value.key,
value.referenceTokenId.toHex(),
bitxor_sdk_1.TokenRestrictionType[value.restrictionType],
value.restrictionValue,
);
});
}
});
} else {
console.log(
'\n The token does not have token global restrictions assigned.',
);
}
},
(err) => console.log(err),
);
// replace with node endpoint
try (final RepositoryFactory repositoryFactory = new RepositoryFactoryVertxImpl(
"NODE_URL")) {
final RestrictionTokenRepository restrictionRepository = repositoryFactory
.createRestrictionTokenRepository();
// replace with tokenId
final String tokenIdHex = "634a8ac3fc2b65b3";
final TokenId tokenId = new TokenId(tokenIdHex);
TokenRestrictionSearchCriteria criteria = new TokenRestrictionSearchCriteria()
.tokenId(tokenId);
List<TokenGlobalRestriction> restrictions = TokenRestrictionPaginationStreamer
.global(restrictionRepository, criteria).toList().toFuture().get();
final JsonHelper helper = new JsonHelperJackson2();
System.out.println(helper.prettyPrint(restrictions));
}
bitxor-cli restriction tokenglobal --token-id 634a8ac3fc2b65b3