How to store data on the blockchain?
Blockchain is a reliable, robust and secure data storage.
Well not in a general sense, blockchain is designed to host financial data in a robust and secure manner. Blockchains are usually not made to host arbitrary data, or are they? Blockchains, by design and definition, define a specific type of database, designed for dealing with financial transactions.
Blockchains allow you to write once, knowing that your content is stored forever, and read your content an infinite number of times. Typically, that content is limited to financial data and smart contracts, but it does not have to be. The immutable, distributed, and secure data storage model makes storing an actual file on-chain very appealing. Some blockchains offer the possibility to append data to a transaction, but generally with data size restrictions, and only really meant for small bits of data like hashes and links.
As you can see, storing data on the V Systems blockchain is two orders of magnitude cheaper than storing data on Ethereum. Really, you shouldn’t take this as a criticism of Bitcoin, Ethereum, or Tezos. The fact is, they just weren’t designed to be used that way.
V Systems blockchain has been designed with data in mind. Thanks to V Systems economic system data is first class citizen, as transaction fees are burned and there is no fee economy.
Keeping your application state on V Systems isn’t just more convenient it’s cheaper as well.
V Systems Blockchain Database
Truly distributed applications that are composed between multiple blockchain systems require a well-designed way to store arbitrary application states — for all the strings and logs that are usually seen as “clogging” blockchains.
At V Systems, we’ve been working to ensure that creating Distributed applications is just as easy as developing traditional software using a regular database as your back end.
Have you ever wanted to store state forever, without a long-term commitment to running an expensive server?
V. Systems has exactly the solution for your needs. Our node software comes with a visually appealing REST API on port 9922. It’s a breeze to set up a V. Systems node with Docker.
For this Tutorial, you’ll need:
- 1 VSYS per Database transaction
- A mobile phone with Walk Wallet
- 10GB of Disk Space
- 24 hours for Sync Time
- A good night's sleep
- A cup of coffee
- 30 minutes to play with the V Systems Database
Mac or Linux, with Docker installed on your computer, you can run:
docker run — rm -itd — name vsys -p 9922:9922 -v `pwd`/vsys-chain-data:/opt/coin/data mixhq/vsystems
Windows: Note: you cannot copy/paste this word for word. You’ll need to enter your username where it says YOUR_USER_NAME_HERE
.
docker run --rm -itd --name vsys -p 9922:9922 --volume //c/Users/YOUR_USER_NAME_HERE/vsys:/home/project mixhq/vystems
That will get a V Systems node up and running for you and put the chain’s data in a folder called “vsys-chain-data”. It the node should come up almost immediately, but it’ll take about 24 hours to sync. Go, have a coffee, do some work, have a great night’s rest, and when you return to this, you’ll be ready to use the V. Systems database endpoint, which will be available to you at http://localhost:9922.
V Systems node generates a wallet address when they come up. You can either use that generated wallet address or configure a seed in the config file for your node.
There are two ways to learn your V Systems node’s address:
Curl
For terminal warriors.
curl -X GET "http://localhost:9922/addresses" -H "accept: application/json"
Swagger UI
Click here and use the “try it out” button to try making a call to the “addresses” endpoint, which returns the addresses controlled by your node.
Once you have your node’s address, something like ARKYdc1pgGSefeCjNNkzWwnoKBVVMDYzex7
, you'll need to use your mobile wallet to send some VSYS coins to your node.
The creator of the Dockerfile used in this tutorial has set the API key to vsys
. If you use the Dockerfile in production, please make sure to edit vsys-mainnet.conf
and build the Docker image for yourself with a different API key.
When you enter the node’s Web UI, click the lock icon where it says “authorize” and enter your API key, vsys
.
When using the V Systems Database, you’ll need to format your data in a certain way. Here is an example of a valid transaction:
{
"sender": "ARKYdc1pgGSefeCjNNkzWwnoKBVVMDYzex7",
"dbKey": "BlogPost",
"dataType": "ByteArray",
"data": "VSYS has exactly the solution for your needs. Our node software comes with a visually-appealing REST API on port 9922. It's a breeze to set up a VSYS node with Docker.",
"fee": 100000000,
"feeScale": 100
}
It’s important to note that there are only three fields here that you need to be concerned with as a user:
- sender: This is the address that you’re sending from, for example ARKYdc1pgGSefeCjNNkzWwnoKBVVMDYzex7.
- dbKey: This is the “key” in the V. Systems Database’s key:value system. It can be up to 30 bytes, and is case sensitive.
- data: This is the “value” in the V. Systems Database’s key:value system. It can be up to 16kb in size, and must be formatted as a string. Currently, escape characters will cause it to reject your transaction.
On a successful transaction, you’ll get a response from your node like this one:
{
"type": 10,
"id": "2WgibyK1D54t5tVydJb9AB2TK26EX761drDo1WFE97RG",
"fee": 100000000,
"feeScale": 100,
"timestamp": 1591696400727981800,
"proofs": [
{
"proofType": "Curve25519",
"publicKey": "3zxfs9qLeY9jdpF6WkLbgUddfyeZM5puuCWDgBzr43D4",
"address": "ARKYdc1pgGSefeCjNNkzWwnoKBVVMDYzex7",
"signature": "2ZCJafNYWxSYznrFpipuCNSQnCvA8Rb7iNThFKFJNZjN6ttonmWhh8h7reMEW1HyeTEUsduNmiemNHX6FXADUivc"
}
],
"dbKey": "BlogPost",
"entry": {
"data": "VSYS has exactly the solution for your needs. Our node software comes with a visually-appealing REST API on port 9922. It's a breeze to set up a VSYS node with Docker.",
"type": "ByteArray"
}
}
To fetch data that you’ve stored in the V Systems Database, you can:
curl -X GET "https://wallet.v.systems/api/database/get/ARKYdc1pgGSefeCjNNkzWwnoKBVVMDYzex7/BlogPost" -H "accept: application/json"
You should get something like this back:
{
"data": "VSYS has exactly the solution for your needs. Our node software comes with a visually-appealing REST API on port 9922. It's a breeze to set up a VSYS node with Docker.",
"type": "ByteArray"
}
There are many ways that you can use our Blockchain Database, but here are three examples that our team came up with while preparing this article and documenting our Database system:
Content Storage for decentralized twitter or blogging
As outlined in the examples above, you can store tweets/posts to V. Systems and retrieve them from anywhere in the world, at any time, from any app.
You’ve got the option of having your users sign their own transactions and broadcasting them to the network, or signing their transactions from your node, as outlined in this article.
IOT data storage
Maybe you’ve got a process or a system somewhere and you’d like to log its activity continually. Let’s just suppose that it produces 16kb of logs per day, and you can compress those logs down to 8kb/day. Storing all of your logs for a year would cost just 182.5 VSYS.
This could be used for other applications as well, like storage of temperature data from a sensor. As you’ll see below, using compression and transaction batching can make the V Systems database very powerful indeed.
Application States
Now suppose that you’ve got an application that generates 100kb of state daily, and your users want to know that it is stored securely, forever. What you can do is batch that state into 16kb compressed groups. Let’s assume that you can get 32kb of state into a compressed 16kb transaction. For 3 VSYS coins per day, you can safely store your application’s state so that you can retrieve it at any time.
Therefore, your app no longer needs a database. It just has to connect to the V. Systems database, and can run as a minimal process.
Don’t store data on the Blockchain
But please, do. — V Systems
The current thinking is that application state, or any other arbitrary data, should not live on-chain and should instead be stored off-chain in a centralized database. The V Systems Database sets a new paradigm in the design of distributed state storage systems. Data is a first class citizen on the V Systems blockchain, up to 16 kB of data can be inserted into the blockchain using our database/put
API call.
What we’re saying is this: all of that undesirable state that you’re not supposed to store on Bitcoin, Ethereum, or Tezos, but would love to, fits really well in the VSYS database.
If you’re building dapps, you don’t need to change your whole application’s design. You can keep your token where it is, and you can easily begin storing state on the V Systems blockchain. Our setup is pretty flexible: You can either run a node and sign each transaction yourself on behalf of users, or you can have your users in possession of a key that can sign transactions that your app broadcasts to the V Systems network.
Stay Connected
We continue to regularly iterate new features into V Systems to provide developers a more stable and user-friendly platform. Community participation is encouraged, as feedback provides insight into the specific needs of developers. If you would like to offer feedback on VSYS 2.0 and work more closely with our team, you can contact our developer relations team at Github.
Twitter: https://twitter.com/VSYSCoin
Telegram:https://t.me/VSYSOfficialGroup
Medium:https://medium.com/vsystems
YouTube: shorturl.at/mxX09
Reddit:https://www.reddit.com/r/V_SYSTEMS/
Github: https://github.com/virtualeconomy/v-systems
Other Useful Links
VSYS Official Website: https://www.v.systems
Supernode Ranklist: https://vsysrate.com/
VSYS Blockchain Explorer: https://explorer.v.systems/