Skip to main content

AssetLeaves

AssetLeaves queries for the set of asset leaves (the values in the Universe MS-SMT tree) for a given asset_id or group_key. These represents either asset issuance events (they have a genesis witness) or asset transfers that took place on chain. The leaves contain a normal Taproot Asset proof, as well as details for the asset.

Source: universerpc/universe.proto

gRPC

rpc AssetLeaves (ID) returns (AssetLeafResponse);

REST

HTTP MethodPath
GET /v1/taproot-assets/universe/leaves/asset-id/{asset_id_str}

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_id: <bytes>,
asset_id_str: <string>,
group_key: <bytes>,
group_key_str: <string>,
proof_type: <ProofType>,
};
client.assetLeaves(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "leaves": <AssetLeaf>,
// }

Messages

universerpc.ID

Source: universerpc/universe.proto

FieldgRPC TypeREST TypeREST Placement
asset_id
bytesstringquery
asset_id_str
stringstringpath
group_key
bytesstringquery
group_key_str
stringstringquery
proof_type
ProofTypestringquery

universerpc.AssetLeafResponse

Source: universerpc/universe.proto

FieldgRPC TypeREST Type
leaves
AssetLeaf[]array

Nested Messages

taprpc.AnchorInfo

FieldgRPC TypeREST Type
anchor_tx
bytesstring
anchor_block_hash
stringstring
anchor_outpoint
stringstring
internal_key
bytesstring
merkle_root
bytesstring
tapscript_sibling
bytesstring
block_height
uint32integer

taprpc.Asset

FieldgRPC TypeREST Type
version
AssetVersionstring
asset_genesis
GenesisInfoobject
amount
uint64string
lock_time
int32integer
relative_lock_time
int32integer
script_version
int32integer
script_key
bytesstring
script_key_is_local
boolboolean
asset_group
AssetGroupobject
chain_anchor
AnchorInfoobject
prev_witnesses
PrevWitness[]array
is_spent
boolboolean
lease_owner
bytesstring
lease_expiry
int64string
is_burn
boolboolean
script_key_declared_known
boolboolean
script_key_has_script_path
boolboolean
decimal_display
DecimalDisplayobject

taprpc.AssetGroup

FieldgRPC TypeREST Type
raw_group_key
bytesstring
tweaked_group_key
bytesstring
asset_witness
bytesstring
tapscript_root
bytesstring

taprpc.DecimalDisplay

FieldgRPC TypeREST Type
decimal_display
uint32integer

taprpc.GenesisInfo

FieldgRPC TypeREST Type
genesis_point
stringstring
name
stringstring
meta_hash
bytesstring
asset_id
bytesstring
asset_type
AssetTypestring
output_index
uint32integer

taprpc.PrevInputAsset

FieldgRPC TypeREST Type
anchor_point
stringstring
asset_id
bytesstring
script_key
bytesstring
amount
uint64string

taprpc.PrevWitness

FieldgRPC TypeREST Type
prev_id
PrevInputAssetobject
tx_witness
bytes[]array
split_commitment
SplitCommitmentobject

taprpc.SplitCommitment

FieldgRPC TypeREST Type
root_asset
Assetobject

universerpc.AssetLeaf

FieldgRPC TypeREST Type
asset
Assetobject
proof
bytesstring

Enums

taprpc.AssetType

NameNumber
NORMAL
0
COLLECTIBLE
1

taprpc.AssetVersion

NameNumber
ASSET_VERSION_V0
0
ASSET_VERSION_V1
1

universerpc.ProofType

NameNumber
PROOF_TYPE_UNSPECIFIED
0
PROOF_TYPE_ISSUANCE
1
PROOF_TYPE_TRANSFER
2