provenance-io / metadata-asset-model

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provenance Blockchain Reference Use Case Data Model

This repository contains a protobuf data model reference standard for the Provenance Blockchain Metadata module tailored for usage in the 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 — with language bindings for Java and Kotlin.

Status

Build stability-beta License LOC

Publications

Latest Release

JAR

Maven Artifact

Maven Usage

<dependency>
  <groupId>io.provenance.model</groupId>
  <artifactId>metadata-asset-model</artifactId>
  <version>${version}</version>
</dependency>

Gradle Usage

Groovy

implementation 'io.provenance.model:metadata-asset-model:${version}'

Kotlin

implementation("io.provenance.model:metadata-asset-model:$metadataAssetModelVersion")

Useful Links

Example Usage

This example shows how an NFT image file might be defined for usage in the P8e Contract Execution Environment, with the object hash stored on the blockchain through the metadata module. The full source code can be found in AssetTest.

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

val asset1 = asset {
    id = UUID.randomUUID().toProtoUUID()
    type = FileNFT.ASSET_TYPE
    description = file.name
    kv.put(FileNFT.KEY_FILENAME, file.name.toProtoAny())
    kv.put(FileNFT.KEY_SIZE, fileBytes.size.toLong().toProtoAny())
    kv.put(FileNFT.KEY_BYTES, fileBytes.toProtoAny())
    kv.put(FileNFT.KEY_CONTENT_TYPE, "image/png".toProtoAny())
}

The JSON representation of this asset would look something 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", // Value truncated
        },
        "content-type": {
            "type_url": "type.googleapis.com/google.protobuf.StringValue",
            "value": "CglpbWFnZS9wbmc="
        }
    }
}

About

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

License:Apache License 2.0


Languages

Language:Kotlin 75.7%Language:Shell 24.3%