diff --git a/README.md b/README.md new file mode 100644 index 0000000..ffd9df6 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Overview + +httXrp is a proof of concept for a truly serverless web architecture. If serverless simply means "a server owned by someone else", httXrp pushes that definition to its limit. + +# How it works + +## 1: Getting data into and out of the blockchain + +Transactions on the ripple blockchain are allowed to carry up to 1kB of arbitrary data via the memo field. +We can use this to store data of any size by building a tree of references between these transactions that can then be reassembled by reading them back from the blockchain. +In order to generate these transactions a library called [xrpio](https://gitea.nitowa.xyz/npm-packages/xrpio.git) is used. + +Highly simplified, you can visualize the process like this: + +![xrpio treewrite](https://i.imgur.com/G2HofSE.gif) + +## 2: Abstracting the webserver away from the web + +Using tools like `webpack`, it is possible to condense even modern complex single-page-applications into a single html file. As `xrpio` is written in JavaScript, it is even possible to embed it into such an HTML file, the use of which will become more clear a few paragraphs below. + +Since such a condensed HTML file is effectively nothing more than a long string it is possible to use `xrpio` to store them into the ripple blockchain and to retrieve them via a single identifying hash. + +![Webserverless web](https://i.imgur.com/Y0TgzVi.gif) + +## 3: Dynamic web applications without a backend + +Superficially, this technique is limited to serving static webpages, as there is no *real* backend serving these pages. However, since it is possible to embed `xrpio` into such a "static" page, it is possible to listen for transactions on the Ripple blockchain containing valid xrpio hashes and to dynamically update the webpage's content based on the stored data. + +# Credits + +- This project was originally inspired by indImm (https://ndm-inf.github.io/ndm/main), a ripple-based file storage using IPFS. +- xrpio (https://gitea.nitowa.xyz/npm-packages/xrpio.git) is heavily used in the technical architecture of this project. It is also written and maintained by me. \ No newline at end of file diff --git a/gateway/index.html b/gateway/index.html index 5a27138..0c25048 100644 --- a/gateway/index.html +++ b/gateway/index.html @@ -5,6 +5,7 @@ + Loading ... diff --git a/package-lock.json b/package-lock.json index b7fae10..1148507 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,10 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "buffer": "^6.0.3", "chai": "^4.3.4", "node-fetch": "^2.6.1", - "xrpio": "^0.1.6", + "xrpio": "^0.1.7", "xrpl": "^2.6.0-beta.0" }, "devDependencies": { @@ -3684,9 +3685,9 @@ } }, "node_modules/xrpio": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/xrpio/-/xrpio-0.1.6.tgz", - "integrity": "sha512-SHm3NfrRv9i82OWrUdyB+Djn0Zr6qwwMfs/wemNR1pf2ajorfiOPpWnvKQTgAZcfgS2DliIfMuF8nRiqfXlmmg==", + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/xrpio/-/xrpio-0.1.7.tgz", + "integrity": "sha512-X/Hxlf31KC1OONq7NYQ518Esd8LHYpyc/RFN9F1J9Nr8WEjgz/XaJDR4IakV7MrNeC3uIRz6/qGFPFWHw2Rr+g==", "dependencies": { "ripple-lib": "^1.10.0", "xrpl": "^2.1.1" @@ -6717,9 +6718,9 @@ "requires": {} }, "xrpio": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/xrpio/-/xrpio-0.1.6.tgz", - "integrity": "sha512-SHm3NfrRv9i82OWrUdyB+Djn0Zr6qwwMfs/wemNR1pf2ajorfiOPpWnvKQTgAZcfgS2DliIfMuF8nRiqfXlmmg==", + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/xrpio/-/xrpio-0.1.7.tgz", + "integrity": "sha512-X/Hxlf31KC1OONq7NYQ518Esd8LHYpyc/RFN9F1J9Nr8WEjgz/XaJDR4IakV7MrNeC3uIRz6/qGFPFWHw2Rr+g==", "requires": { "ripple-lib": "^1.10.0", "xrpl": "^2.1.1" diff --git a/package.json b/package.json index 0f63f13..ecaec94 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,10 @@ "author": "", "license": "ISC", "dependencies": { + "buffer": "^6.0.3", "chai": "^4.3.4", "node-fetch": "^2.6.1", - "xrpio": "^0.1.6", - "buffer": "^6.0.3", + "xrpio": "^0.1.7", "xrpl": "^2.6.0-beta.0" }, "devDependencies": { diff --git a/src/Browser.ts b/src/Browser.ts deleted file mode 100644 index bfb545b..0000000 --- a/src/Browser.ts +++ /dev/null @@ -1,5 +0,0 @@ -(window as any).global = window; -(window as any).Buffer = (window as any).buffer.Buffer; -const rippleApi = require('xrpio') -window['xrpIO'] = rippleApi.xrpIO - diff --git a/src/Gateway.ts b/src/Gateway.ts index ef377c2..e214313 100644 --- a/src/Gateway.ts +++ b/src/Gateway.ts @@ -1,8 +1,7 @@ -(window as any).global = window; -(window as any).Buffer = (window as any).Buffer || require('buffer/').Buffer; (window as any).buffer = (window as any).Buffer -import { xrpIO } from 'xrpio'; -(window as any).xrpIO = xrpIO; +//import { xrpIO } from 'xrpio'; + +declare const xrpIO declare const DATA_HASH: string const api = new xrpIO("wss://s.altnet.rippletest.net:51233")