Metadata and Feedback
Metadata (eg, description and photos about what was sold) and the full text of the feedback that was left for the seller are very important aspects of a transaction. With Ink Protocol, the raw data for these attributes is not directly stored on the blockchain due to the cost of data storage on the Ethereum network. Although it varies with gas cost and the price of Ether, storing 1MB of data on the blockchain can easily cost hundreds of US dollars.
In designing Ink Protocol, we didn't want there to be a restriction on how much metadata could be saved, or limit how long a buyer's comment about a transaction could be, so the Ink Protocol smart contract is designed to store only a hash of the actual metadata and comment.
// Metadata is stored as a hash of the actual metadata
bytes32 _metadata
// The feedback rating is stored on the contract...
uint8 _rating
// ...but the comment is stored as a hash
bytes32 _comment
How Hashing Works
Ink Protocol recommends that marketplaces and apps produce the _metadata
and _comment
hashes using the Keccak-256 hashing algorithm (hexadecimal), which produces a 64-chracter long hexadecimal string (64 hexadecimal characters = 32 bytes). Here's an example in Ruby:
> Digest::SHA3.hexdigest("hello world", 256)
=> "47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"
Apps and marketplaces are expected to hash the actual metadata and comment data and send the resulting hashes in the createTransaction
and provideTransactionFeedback
functions, respectively.
Fetching Raw Data
To obtain the actual metadata and feedback comment, services and applications running on top of Ink Protocol should reference the _owner
of the transaction and request the raw data that produces the hashes.
The exact recommended process for this is still being decided, but we imagine a flow similar to the following:
- An Ink Protocol explorer service ("Service") detects a new transaction or feedback being created on Ink Protocol's smart contract.
- The
_metadata
or_comment
value is47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad
- The
_owner
on the transaction points to a marketplace, "Marketplace"
- Service recognizes Marketplace, and issues a GET request to an endpoint that Marketplace has made publicly known.
GET https://marketplace.example/inkprotocol/hashes/47173285..
returns the following response body:hello world
- The Service verifies that the Keccak-256 hash of
hello world
matches47173285..
, and then storeshello world
in its own database for future reference/display.
The exact means by which marketplaces and apps share their endpoints are still being planned, as are the schemas/formats for storing the raw metadata and feedback comments (JSON is likely to be used).
Updated over 5 years ago