Skip to main content

QueryAssetStats

tapcli universe stats assets QueryAssetStats returns a set of statistics for a given set of assets. Stats can be queried for all assets, or based on the: asset ID, name, or asset type. Pagination is supported via the offset and limit params. Results can also be sorted based on any of the main query params.

Source: universerpc/universe.proto

gRPC

rpc QueryAssetStats (AssetStatsQuery) returns (UniverseAssetStats);

REST

HTTP MethodPath
GET /v1/taproot-assets/universe/stats/assets

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:10029'
const MACAROON_PATH = 'TAPROOT-ASSETS_DIR/regtest/taproot-assets.macaroon'
const TLS_PATH = 'TAPROOT-ASSETS_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('universerpc/universe.proto', loaderOptions);
const universerpc = grpc.loadPackageDefinition(packageDefinition).universerpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new universerpc.Universe(GRPC_HOST, creds);
let request = {
asset_name_filter: <string>,
asset_id_filter: <bytes>,
asset_type_filter: <AssetTypeFilter>,
sort_by: <AssetQuerySort>,
offset: <int32>,
limit: <int32>,
direction: <SortDirection>,
};
client.queryAssetStats(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "asset_stats": <AssetStatsSnapshot>,
// }

Messages

universerpc.AssetStatsQuery

Source: universerpc/universe.proto

FieldgRPC TypeREST TypeREST Placement
asset_name_filter
stringstringquery
asset_id_filter
bytesstringquery
asset_type_filter
AssetTypeFilterobjectquery
sort_by
AssetQuerySortobjectquery
offset
int32integerquery
limit
int32integerquery
direction
SortDirectionobjectquery

universerpc.UniverseAssetStats

Source: universerpc/universe.proto

FieldgRPC TypeREST Type
asset_stats
AssetStatsSnapshot[]array

Nested Messages

universerpc.AssetStatsAsset

FieldgRPC TypeREST Type
asset_id
bytesstring
genesis_point
stringstring
total_supply
int64string
asset_name
stringstring
asset_type
AssetTypestring
genesis_height
int32integer
genesis_timestamp
int64string
anchor_point
stringstring

universerpc.AssetStatsSnapshot

FieldgRPC TypeREST Type
group_key
bytesstring
group_supply
int64string
group_anchor
AssetStatsAssetobject
asset
AssetStatsAssetobject
total_syncs
int64string
total_proofs
int64string

Enums

taprpc.AssetType

NameNumber
NORMAL
0
COLLECTIBLE
1

universerpc.AssetQuerySort

NameNumber
SORT_BY_NONE
0
SORT_BY_ASSET_NAME
1
SORT_BY_ASSET_ID
2
SORT_BY_ASSET_TYPE
3
SORT_BY_TOTAL_SYNCS
4
SORT_BY_TOTAL_PROOFS
5
SORT_BY_GENESIS_HEIGHT
6
SORT_BY_TOTAL_SUPPLY
7

universerpc.AssetTypeFilter

NameNumber
FILTER_ASSET_NONE
0
FILTER_ASSET_NORMAL
1
FILTER_ASSET_COLLECTIBLE
2

universerpc.SortDirection

NameNumber
SORT_DIRECTION_ASC
0
SORT_DIRECTION_DESC
1