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
Publications
JAR
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="
}
}
}