Sending data to DAG
You can store arbitrary data (any sequence of bytes) in Obyte public DAG. Some special types of data also supported, like 'text', 'profile', 'poll', etc.
Data with any structure
To send data
to DAG database, code below is a minimal that you can use. Since the opts.messages
is array, it means that all the examples on this page can be changed to multi-message transactions.
AAs can be triggered with data by manually entering the key/value pairs to GUI wallet, prompting users to submit pre-filled Send screen, making the AA to trigger another AA or with the script from headless wallet.
Key-value data feed
Previous example shows how to send any data to DAG, but if you would want to store data that is searchable and can be used in smart-contracts or autonomous agents then you would need to post it as key-value pairs and with app type data_feed
. If we also send it always from the same first address in our wallet then we have basically become an oracle.
Profile about yourself
Anybody on Obyte network can post some data about themselves, which will be linked to their address. This app type is called profile
. Payload for that message can contain any keys. For example, obyte.io web service lets you post a profile with keys like this:
Attestation profile
Attestation profile is similar to previous one with one difference that attestation
type message are posted by somebody and they describe somebody else. These profiles are used to do KYC by asking user to provide data about themselves from trusted attestor.
Private/Public attestations
Real Name Attestation bot creates an attestation
profile, which keeps all the data private on user device while makes it possible for the others to recognize unique users by user_id
(it's a salted hash of first_name
, last_name
, dob
and country
) and also makes it possible to validate with profile_hash
if user provides them a private profile.
In case user would want to make their profile public like with Email Attestation and Steem Attestation, true
could be sent as a second parameter of hideProfile()
function. To avoid people doxxing themselves, the possibility to make public attestation with Real Name Attestation has not been included. This choice is only on Email Attestation and Steem Attestation.
In order for the user to share private profile with others, your bot should also send the private profile to user's wallet.
Public only attestations
If there is no plan to provide private attestations and all the attestation will always be public then there is no need for user_id
. Then the attestation profile can be as simple as this, but the attestator needs to make sure that the same username attestation is not done to multiple users. One example of that kind is Username Attestation bot.
For public attestation, there is not private profile to send to user's wallet because the bots who need information about the user could simply just retrieve the attestation profile from the DAG.
Poll question and choices
Anybody can post a poll and let others vote on it, this can be done like this data and it will also appear on obyte.io web service from where it will direct users to Poll chat bot.
Plain text data
And last and not the least, it is possible to post plain text to DAG too.
More examples
Shorter code examples using composer library are available in "/tools" folder of headless-wallet.
If you wish to send data to DAG database periodically then full code examples for price oracle, bitcoin oracle or sports oracle can be found on Github.
Last updated