Bitcoin Forum
May 06, 2024, 11:54:54 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Alternate cryptocurrencies / Announcements (Altcoins) / [ANN][Datacoin] Next step: web applications inside blockchain (demo) on: January 09, 2014, 12:22:30 AM
Hello!

Datacoin blockchain started about two months ago. Thank you to all of you supporting Datacoin. It exists because of your support.

Now we can start developing blockchain-based web applications. Note that this feature doesn't touch sources of Datacoin daemon or qt-wallet: if you are not interested in this it you can still use Datacoins and without understanding this post. Blockchain-based web applications require a http-server that redirects HTTP requests from browser to daemon. This is implemented now with Perl (dtc_http_server.pl). Yes, I know I would have to do it using C++. I'll rewrite it later.

Why web-applications inside blockchain are good?

1. they are protected from being deleted or censored
2. they work locally and don't require a live Internet connection
3. web interface is convenient to users
4. no new technologies are required for developement: HTTP, AJAX and JSON RPC are simply linked together Wink

Datacoin HTTP server is very simple and it is intended to work locally on end-user's machine.

Types of requests supported by Datacoin local HTTP server

NB: NET can be 'dtc' or 'dtc-testnet'

1. Get data from blockchain
http://localhost:PORT/NET/get/TXHASH -> data from tx with TXHASH will be sent back (data is assumed to be in Envelope format - see envelope.proto file)

Example:
http://localhost:8080/dtc/get/40a3eb9624528008a87d9119dbed4041d45c9f6483ecd52a7b24f9c8b4fdf548

2. Call daemon's method
http://localhost:PORT/NET/rpc/METHOD(/ARGS) -> json-rpc call to daemon's METHOD will be performed and resulting json will be sent back to browser

Several arguments are possible in form arg1/arg2/arg3/...

Example:
http://localhost:8080/dtc/rpc/getblockhash/1000

Code:
{
 "result" : "ce3ca3728ee050bf14d8f9a059f13c0062ca303cf2c982796c7dec2ce10f13c6",
 "error" : null,
 "id" : null
}

NB: due to security reasons only 'getinfo', 'getmininginfo', 'getblock', 'getblockhash' and 'getrawtransaction' are supported now. Later all reading methods will be added. 'sendtoaddress' and other money-spending methods probably will be added also but some security issues are to be considered before in order to protect users from theft.

3. Call http local server's method
http://localhost:PORT/NET/lsrpc/METHOD(/ARGS) -> http server will handle this method itself (or translate to several requests to daemon).

There is only one example of lsrpc methods now: 'getenvelope'. It parses tx.data field of a given transaction as an Envelope and returns envelope in json format (without 'Data'). This method is needed to get metadata easily.

Example:
http://localhost:8080/dtc/lsrpc/getenvelope/40a3eb9624528008a87d9119dbed4041d45c9f6483ecd52a7b24f9c8b4fdf548

Code:
{
  "result":
  {
    "FileName":"blockexplorer.html",
    "ContentType":"text/html",
    "Compression":"1",
    "PublicKey" : "MIGJA... a lot of base64 letters ...AE=",
  }
}

Demo
In order to demonstrate this in action I've sent 'Block explorer' application in transaction 40a3eb9624528008a87d9119dbed4041d45c9f6483ecd52a7b24f9c8b4fdf548. Here is an instruction on how to access it from your own computer with local HTTP server (actually this will be too difficult for 99% of users, I need to rewrite server using C++ and deliver it as a precompiled binary):

Before you start: DON'T do this on the machine with many coins!!! Setup a different user account on Windows (or Linux) or a virtual machine. There is a lot of possible bugs in this code that can lead to loss of money.

Now you are warned. Let's continue.

1. backup yout wallet.dat and protect it with password

2. git clone https://github.com/foo1inge/datacoin-browser.git

3. install all required CPAN modules (the way to do this depends from your Perl distribution, ask Perl guru if you don't know how to do this). Here is list of modules:

Code:
HTTP::Server::Simple::CGI
Google::ProtocolBuffers
MIME::Base64
IO::Compress::Bzip2
IO::Uncompress::Bunzip2
Crypt::OpenSSL::RSA
JSON::RPC::Client
File::HomeDir
Data::Dumper

4. start Datacoin daemon ('getdata' RPC method is required. It was commited two weeks ago and probably you have to update your daemon).

5. cd datacoin-browser/perl/

6. perl dtc_http_server.pl --http-port=8080
This will start local HTTP server on port 8080. In order to see Datacoin testnet add "--testnet=1" option - it will connect to daemon working in testnet.

7. go to http://localhost:8080/dtc/get/40a3eb9624528008a87d9119dbed4041d45c9f6483ecd52a7b24f9c8b4fdf548

8. enjoy

You can deploy this on any machine. Here is this application deployed on Amazon EC2 (micro instance, very slow):
http://ec2-54-201-144-165.us-west-2.compute.amazonaws.com/dtc/get/40a3eb9624528008a87d9119dbed4041d45c9f6483ecd52a7b24f9c8b4fdf548

Blockexplorer application consists of three transactions:

40a3eb9624528008a87d9119dbed4041d45c9f6483ecd52a7b24f9c8b4fdf548 - blockexplorer.html
465ca75b6dedf70bc85db24548ee99bab776028f9295116afba4fa1e4838ff5f - blockexplorer.js
73b7c7165a51f604040e17681705a39145392691a0447266b9074a2ad9140327 - datacoin-logo.png


All these files are accessed by TXID (not by names!) the following way (snippets from blockexplorer.html):

Code:
<script
  src="/dtc/get/465ca75b6dedf70bc85db24548ee99bab776028f9295116afba4fa1e4838ff5f"
  type="text/javascript"
  encoding="UTF-8">
</script>

Code:
<td style="padding-right:6px">
<img
  src="73b7c7165a51f604040e17681705a39145392691a0447266b9074a2ad9140327"
  alt="Datacoin logo"/>
</td>

Blockexplorer does following steps while starting:

1. getinfo RPC call (to get current height)
2. getblockhash / getblock for each block in cycle
3. getrawtransaction for each transaction
4. getenvelope for each transaction with data

All these calls are coded as ordinary AJAX in blockexplorer.html.

Important issues for web developers on how to develop applications for Datacoin

1. Start development in testnet

Testnet block explorer: http://ec2-54-201-144-165.us-west-2.compute.amazonaws.com:81/dtc-testnet/get/7fead7473c448b2d69d0e62354dedd59895a1ab099c1835155d83f7327c5156a

2. Never use specific IP or PORT in URLs - only relative URLs are meaningful (user can start local HTTP server on any IP:PORT).
In your HTML code instead of doing

Code:
<a href="http://localhost:8080/dtc/get/40a3eb9624528008a87d9119dbed4041d45c9f6483ecd52a7b24f9c8b4fdf548">...</a>

use relative URL:

Code:
<a href="/dtc/get/40a3eb9624528008a87d9119dbed4041d45c9f6483ecd52a7b24f9c8b4fdf548">...</a>

3. Use "--content-type" argument of dtc_put_file.pl script to set a "Content-type" HTTP attribute for your files.

Here is an example:
Code:
perl dtc_put_file.pl --content-type="text/html" blockexplorer.html

4. Use "--add_key" argument of dtc_put_file.pl script and save private key (it will be printed on screen) in a secure place in order to upate your application later.

Here is a full example:
Code:
perl dtc_put_file.pl --add_key=true --content-type="text/html" blockexplorer.html

NB: update feature isn't implemented yet Sad I'm working on it now.

Datacoin development plans regarding blockchain-based web-applications:
(I don't mention here issues not related to the topic)

1. bugfixing

2. Update feature (see detailed description of update scenario in envelope.proto file)

3. Big files (more 128Kb) feature

4. C++ version of local HTTP server

5. "senddata" from local HTTP server

6. Access to P2P file sharing networks from local HTTP server (something like localhost:8080/kademlia/HASH). Needs some investigation.
2  Alternate cryptocurrencies / Announcements (Altcoins) / [ANN][Datacoin] Datacoin blockchain start announcement (Minor code upd + logo) on: November 05, 2013, 10:01:26 PM
Hi!

I'm going to run an experimental cryptocurrency (just another fork, nearly nothing new :-/). Here are some technical details:

- Datacoin is a Primecoin-fork: same PoW method

- Binary data field added to all transactions. Data field size is limited to 128Kb. Block size is limited to 1Mb.
Code:
     unsigned int nLockTime;
+    std::vector<unsigned char> data;

- senddata RPC method is added: it creates a tx with data and the change sent back. The example below shows how to save a bzip2 compressed file into the blockchain. senddata method requires base64 encoded data as an argument. senddata method prints txid on success.

Code:
bzip2 -c -9 filename.txt | base64 -w 0 | xargs -I XX datacoind senddata XX

- getdata RPC method:

Code:
datacoind getdata XX

- MIN_TX_FEE is set to 0.05 (Primecoin value is 0.01) => fully loaded block will give 51.2 coins to miner additionally to block reward.

- Simple web applications can be stored inside blockchain. See details here: https://bitcointalk.org/index.php?topic=405992.0

Datacoin is intended to be reliable censorship-free data storage and a currency to pay for this storage. Money transfer isn't the first purpose of Datacoin.

Data is stored in the blockchain "forever" (as long as blockchain exists) and can be retrieved with tx hash as an identifier. I consider this as a platform to be used by applications (and not directly by users): torrent trackers, encrypted messaging services etc.. I don't consider blockchain as a place to store heavy data like video files: this should be too expensive. Instead I propose to store in Datacoin torrent files, certificates, possibly some HTML pages and other kinds of metainformation.

As soon as Datacoin is a STORAGE, blockchain will be HEAVY. Max 1 year blockchain size is 1Mb * 60 mins * 24 hours * 365 days = 513.28 Gb

Transactions without data are also supported Wink

There is no way to store file name or file type in the blockchain. If required file name and type are to be handled by upper-level protocol.

I plan to launch a Datacoin blockchain today: Nov 17, 13:15 GMT. Additional update will be published in one hour before launch.
Blockchain will contain only genesis block at the beginning and the difficulty will be reasonably high.

Official code repository
https://github.com/foo1inge/datacoin - Primecoin fork with data in tx and corresponding RPC (not useful just now because nobody has money for fee).
https://github.com/foo1inge/datacoin-hp - Primecoin-hp fork with data in tx (and no RPC ... I'll port this later). You should use this for mining because it is faster.

Scripts
https://github.com/foo1inge/datacoin-browser - Perl scripts for putting and getting files to/from blockchain.
ATTN1: Be sure you understand what you do. Please review scripts before using them (seriously).
ATTN2: Until datacoin-hp update you need non-hp version of datacoin for these scripts.

Binary
Datacoin-hp Windows binary (still i686 arch): http://sourceforge.net/projects/datacoin/files/datacoin-qt-131204.zip/download .
Linux users have to build binaries themselves: this is more secure and gives better performance. Please check Primcoin build instructions (libgmp for -hp version).

2013-12-04 update:
- 256 bytes getwork support (thanks to yvg1900 for support)
- Checkpoint on 72200
- datacoin-hp supports senddata RPC
- Strings fixed
- Datacoin logo (thanks to Zorrosv for design and maxsolnc for org. help)

Datacoin FAQ

1. What is Datacoin?

Datacoin is both a reliable and decentralized data storage service and a currency to pay for this service.


2. Where my files are actually stored in Datacoin network?

Files are stored on local HDDs of all users participating in the Datacoin network. Each user has it's own full local copy of all Datacoin files.


3. Are my files encrypted in Datacoin?

No. You are responsible to encrypt your files before sending.


4. Is there any way to delete my data from Datacoin blockchain?

No. Once data goes into Datacoin blockchain there is no way to delete this data.


5. Why Datacoin doesn't handle file names and any other details about my files?

Datacoin daemon works with blobs only. This is because it must be a reliable software. Any additional metadata must be strictly verified and this code can lead to bugs. Bugs are bad. But no special rules are required for blobs except of size verification.

There is a upper level protocol (Datacoin envelope) that handles file name, files bigger than 128Kb, file updates and compression. You can follow Datacoin envelope development here: https://github.com/foo1inge/datacoin-browser

Datacoin envelope doesn't need any modification in Datacoin daemon and Qt wallet - JSON RPC connection is enough.
 

6. How much disk space does it take?

1Mb (max block size) * 60 minutes * 24 hours * 365 days = no more than 513Gb per 1 year


7. Is this storage free?

No. Currently fee is 0.05 DTC per 1Kb of data. This standard fee can be changed in future without hardfork.


8. Sender pays fee and who gets this fee?

All fee goes to miners i.e. fee is distributed between nodes supporting Datacoin network proportionally to their mining power.

Fee from fully loaded block is about 50DTC (block reward now is ~11DTC and it decreases).


9. Does the whole concept mean that it is tough to go for Android or IPhone client?

Mobile clients need light wallets in order to see balance and send transactions. Light wallet will interact to some web service instead of storing full blockchain locally.


10. People really need to store more than 513Gb of data per year in decentralized storage. Do you have any plans to increase storage space?

Datacoin is a root storage engine in the decentralized storage service. This storage is both reliable and expensive. I'm now working on concept of personal chains. Personal chains will start from root Datacoin blockchain and will be replicated to nodes by subscription (nodes can choose chains they subscribe to). Datacoin blockchain will handle only identification and some metadata for all personal chains.

Important notes:
- This (personal chains) is only on conceptual level now and will be clarified and prototyped in few months.
- This doesn't mean Datacoin hardfork. Personal chains will be constructed on top of Datacoin network.


11. What is current state of Datacoin project?

Datacoin network [reliable and expensive blob storage in blockchain] - up and running
Datacoin envelope [file storage in blockchain] - under development (Perl prototyping)
Personal chains [more data outside of blockchain] - on conceptual level


12. Who is working on Datacoin project?

I'm working alone for now. I didn't accepted yet anybody into development team but I plan to do this in the future in order to make process more sustainable. Keep in touch and thank you for your support.
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!