/metadata-asset-model

Protobuf data model reference standard for the Provenance Blockchain Metadata module and P8e Contract Execution Environment.

Primary LanguageKotlinApache License 2.0Apache-2.0

Provenance Blockchain Reference Use Case Data Model

This repository contains the protobuf data model reference standard for Provenance Blockchain Metadata module and P8e Contract Execution Environment.

The model includes definitions for generic NFTs (Assets) as well as business domain objects, such as loans and loan servicing data, and Java language-bindings.

Maven

<dependency>
  <groupId>tech.figure.asset</groupId>
  <artifactId>metadata-asset-model</artifactId>
  <version>${version}</version>
</dependency>

Gradle

implementation 'tech.figure.asset:metadata-asset-model:${version}'

Example Usage:

This example shows how an NFT image file might be loaded into the P8e Contract Execution Environment, with the object hash store on the blockchain through the metadata module. Source code for this example is in AssetTest.

val file = File("src/test/data/logo.png")
val fileBytes = file.readBytes()

val asset1 = AssetOuterClassBuilders.Asset {
    id = UUID.randomUUID().toProtoUUID()
    type = "FILE"
    description = file.name
    putKv(FileNFT.KEY_FILENAME, file.name.toProtoAny())
    putKv(FileNFT.KEY_SIZE, fileBytes.size.toLong().toProtoAny())
    putKv(FileNFT.KEY_BYTES, fileBytes.toProtoAny())
    putKv(FileNFT.KEY_CONTENT_TYPE, "image/png".toProtoAny())
}

The JSON representation of this asset would look like:

{
    "id": "4861c0c0-d46e-4ca2-b765-c66b45a41464",
    "type": "FILE",
    "description": "file",
    "kv": {
        "filename": {
            "type_url": "type.googleapis.com/google.protobuf.StringValue",
            "value": "Cg9pbWFnZSAoMTM4KS5wbmc="
        },
        "size": {
            "type_url": "type.googleapis.com/google.protobuf.Int64Value",
            "value": "CK3zEQ=="
        },
        "bytes": {
            "type_url": "type.googleapis.com/google.protobuf.BytesValue",
            "value": "Cq3zEYlQTkcNChoKAAAADUlIRF... image bytes truncated ...",
        },
        "content-type": {
            "type_url": "type.googleapis.com/google.protobuf.StringValue",
            "value": "CglpbWFnZS9wbmc="
        }
    }
}