Attribute
A module that stores attribute values against addresses/accounts. Keys are managed by the Name module.

Overview

Accounts on the Provenance Blockchain are based around the concept of holding a collection of coins under an address derived from a public key. All transactions with the blockchain must be associated with an account. The Attribute module defines a registry of key/value/type data associated with an address where the data itself is written and controlled by the account that owns the name used in the key.

Attribute Structure

The Attribute structure is simply a key/value structure used to assocate a value to an address.
1
// Attribute holds a typed key/value structure for data associated with an account
2
type Attribute struct {
3
// The attribute name.
4
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
5
// The attribute value.
6
Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
7
// The attribute value type.
8
AttributeType AttributeType `protobuf:"varint,3,opt,name=attribute_type,json=attributeType,proto3,enum=provenance.attribute.v1.AttributeType" json:"attribute_type,omitempty"`
9
// The address the attribute is bound to
10
Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
11
}
Copied!

Attribute Types

Attributes associated to an address are typed:
1
// AttributeType defines the type of the data stored in the attribute value
2
type AttributeType int32
3
4
const (
5
// ATTRIBUTE_TYPE_UNSPECIFIED defines an unknown/invalid type
6
AttributeType_Unspecified AttributeType = 0
7
// ATTRIBUTE_TYPE_UUID defines an attribute value that contains a string value representation of a V4 uuid
8
AttributeType_UUID AttributeType = 1
9
// ATTRIBUTE_TYPE_JSON defines an attribute value that contains a byte string containing json data
10
AttributeType_JSON AttributeType = 2
11
// ATTRIBUTE_TYPE_STRING defines an attribute value that contains a generic string value
12
AttributeType_String AttributeType = 3
13
// ATTRIBUTE_TYPE_URI defines an attribute value that contains a URI
14
AttributeType_Uri AttributeType = 4
15
// ATTRIBUTE_TYPE_INT defines an attribute value that contains an integer (cast as int64)
16
AttributeType_Int AttributeType = 5
17
// ATTRIBUTE_TYPE_FLOAT defines an attribute value that contains a float
18
AttributeType_Float AttributeType = 6
19
// ATTRIBUTE_TYPE_PROTO defines an attribute value that contains a serialized proto value in bytes
20
AttributeType_Proto AttributeType = 7
21
// ATTRIBUTE_TYPE_BYTES defines an attribute value that contains an untyped array of bytes
22
AttributeType_Bytes AttributeType = 8
23
)
Copied!
Keys may appear multiple times in an attribute list. This is allowed so long as the value (more specifically the hash of the value) is unique. This allows flexibility in creating a list of assets (per this example) or any other type of information which may have multiple instances for a single address.
Each of the values is associated with some basic type information. This is required for proper serialization. The intent is to support basic types (int, string) along with platform specific concepts like Bech32 addresses, URIs, JSON structures, and UUIDs. Type information can be associated with limits to protect the system. Examples include bounds on integers, length restrictions for strings, and possibly reference checks for blockchain URIs. These limits will be configured using parameters for the handler running in the daemon process.