Skip to main content

SubscribeMintEvents

SubscribeMintEvents allows a caller to subscribe to mint events for asset creation batches.

Source: mintrpc/mint.proto

gRPC

info

This is a server-streaming RPC

rpc SubscribeMintEvents (SubscribeMintEventsRequest) returns (stream MintEvent);

REST

HTTP MethodPath
POST /v1/taproot-assets/events/asset-mint

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('mintrpc/mint.proto', loaderOptions);
const mintrpc = grpc.loadPackageDefinition(packageDefinition).mintrpc;
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 mintrpc.Mint(GRPC_HOST, creds);
let request = {
short_response: <bool>,
};
let call = client.subscribeMintEvents(request);
call.on('data', function(response) {
// A response was received from the server.
console.log(response);
});
call.on('status', function(status) {
// The current status of the stream.
});
call.on('end', function() {
// The server has closed the stream.
});
// Console output:
// {
// "timestamp": <int64>,
// "batch_state": <BatchState>,
// "batch": <MintingBatch>,
// "error": <string>,
// }

Messages

mintrpc.SubscribeMintEventsRequest

Source: mintrpc/mint.proto

FieldgRPC TypeREST TypeREST Placement
short_response
boolbooleanbody

mintrpc.MintEvent

Source: mintrpc/mint.proto

FieldgRPC TypeREST Type
timestamp
int64string
batch_state
BatchStatestring
batch
MintingBatchobject
error
stringstring

Nested Messages

mintrpc.MintingBatch

FieldgRPC TypeREST Type
batch_key
bytesstring
batch_txid
stringstring
state
BatchStatestring
assets
PendingAsset[]array
created_at
int64string
height_hint
uint32integer
batch_psbt
bytesstring

mintrpc.PendingAsset

FieldgRPC TypeREST Type
asset_version
AssetVersionstring
asset_type
AssetTypestring
name
stringstring
asset_meta
AssetMetaobject
amount
uint64string
new_grouped_asset
boolboolean
group_key
bytesstring
group_anchor
stringstring
group_internal_key
KeyDescriptorobject
group_tapscript_root
bytesstring
script_key
ScriptKeyobject

taprpc.AssetMeta

FieldgRPC TypeREST Type
data
bytesstring
type
AssetMetaTypestring
meta_hash
bytesstring

taprpc.KeyDescriptor

FieldgRPC TypeREST Type
raw_key_bytes
bytesstring
key_loc
KeyLocatorobject

taprpc.KeyLocator

FieldgRPC TypeREST Type
key_family
int32integer
key_index
int32integer

taprpc.ScriptKey

FieldgRPC TypeREST Type
pub_key
bytesstring
key_desc
KeyDescriptorobject
tap_tweak
bytesstring

Enums

mintrpc.BatchState

NameNumber
BATCH_STATE_UNKNOWN
0
BATCH_STATE_PENDING
1
BATCH_STATE_FROZEN
2
BATCH_STATE_COMMITTED
3
BATCH_STATE_BROADCAST
4
BATCH_STATE_CONFIRMED
5
BATCH_STATE_FINALIZED
6
BATCH_STATE_SEEDLING_CANCELLED
7
BATCH_STATE_SPROUT_CANCELLED
8

taprpc.AssetMetaType

NameNumber
META_TYPE_OPAQUE
0
META_TYPE_JSON
1

taprpc.AssetType

NameNumber
NORMAL
0
COLLECTIBLE
1

taprpc.AssetVersion

NameNumber
ASSET_VERSION_V0
0
ASSET_VERSION_V1
1