Storing a significant number of records on the Ethereum blockchain is prohibitively expensive due to the gas costs per byte and is a big challange that often hinders the development of applications that need to create, read, update, and delete various kinds and numbers of records. Although iexec does not deal directly with data storage, it can serve as a middleware-type componenet that can bridge the blockchain with storage protocols such as IPFS.
As IPFS can store any kind of file, it is capable of storing file-based database files such as SQLite files to allow for storage of entire databases and retrieval of such databases on demand.
This iexec application serves as a bridge in such an architecture, to accept query requests, find the relevant DB on IPFS, run queries on the DB, and return the results to the smart contract developer in the form of an IPFS hash.
An example workflow is described below:
-
Pre-requisites:
- User has previously created a SQLite DB and placed the DB file on IPFS, and so also has an IPFS hash of this database file.
- User has developed SQL queries for this DB and has also stored these queries on IPFS, and so also has the IPFS hashes associated to these queries.
-
Steps:
-
User sends DB Hash of SQLite DB on IPFS to Ethereum smart contract: Example DB Hash: e0d123e5f316bef78bfdf5a008837577
-
User sends INSERT, SELECT, UPDATE, OR DELETE query hash to Ethereum smart contract for running it on the SQLite DB: Example Query Hash: a09455733316bef78bfdf5a498576332
-
Upon user request, Ethereum Smart Contract sends query request along with DB hash and query hash to iexec
-
iexec does the work of downloading the database from IPFS using the DB file hash, as well as downloading the full query text from IPFS using the query hash
-
iexec runs the query on the downloaded database
-
iexec gets the results of the query and stores the results on IPFS. Also, stores update database back to IPFS if applicable.
-
iexec returns the result to the smart contract in the form on an IPFS hash. Also, iexec returns the updated DB hash to the smart contract if the database was updated.
-
User can see the query results by using the results hash see full results stored on IPFS
Ethereum provides the smart contracts to send requests to iexec. Ethereum is also in major need of off-chain computation and storage capabilities to complement its smart contract capabilities, so this iexec app helps to fill those resource gaps.
This iexec application allows for clients to use Ethereum contracts to work with databases. The intermediary that runs the required queries on the database usually must do its work on a centralized server that the user must set up and maintain. With this set up, the user does not have to host the database on their own servers (since it exists on IPFS), and the query transactions also do not have to run on any specified server (since iexec will take care of this processing).
