Interplanetary Database: A Database built on top of IPFS and made immutable using Ethereum blockchain.

Overview

IPDB

IPDB (Interplanetary Database) is a key/value store database built on top of IPFS (Interplanetary File System).

Project is intended to be an MVP and it will change during next weeks. It's born as a need for the Retrieval Pinning Protocol built by CryptoNet and YOMI to store data inside a public database which don't belong to a single entity but belong to all network.

Core idea is made by two parts:

  • Use the MFS (Mutable file system) to easily manage and handle json files
  • Use the blockchain (Ethereum or EVM) to save the latest version of the database on-chain

Each node is responsible, of course, of the pinning of the latest version of database to make it accessible also to other users.

Similar to the multiaddr standard we created a standard which defines the user, the database and the version. So each database has it's own dbid which is something like:

/0xEthereumAddress/DatabaseName/<VERSION>

Each version will be stored on-chain and will be recovered later for update or read it. Of course only the owner will be able to store the information on-chain.

Another interesting feature is remote pinning to supported providers Pinata and Web3Storage, if you like to add your provider here please open a pull request. Remote pinning will allow you to have a secure backup of your databases making them more distributed.

Folder structure and technology

Project is pretty simple, you'll find:

  • contract: which contains the contract logic
  • src: which is the main package folder
  • tests: which contains the test files
  • .env: which will contain all your variables, please remember to setup it first.

As you may noticed entire project is a NodeJS module and it will be published on NPM once it will be ready for test.

Run tests

If you want to run some tests you can easily follow these steps, assuming you've NodeJS v16 installed and YARN:

yarn
cp .env.example .env

Now customize your .env file with your own keys, then you're able to run one of the tests:

yarn chain:create

After some seconds you should be able to see something like:

Using provider: https://goerli.infura.io/v3/7e6812ca728848919e64a63a134a1e79
Creating IPFS instance..
Swarm listening on /ip4/127.0.0.1/tcp/4002/p2p/12D3KooWSZy8uChn5WRNyBh12sEK1bheYPwm2U9ikP9GxZUPzPNj
Swarm listening on /ip4/192.168.1.22/tcp/4002/p2p/12D3KooWSZy8uChn5WRNyBh12sEK1bheYPwm2U9ikP9GxZUPzPNj
Swarm listening on /ip4/172.17.0.1/tcp/4002/p2p/12D3KooWSZy8uChn5WRNyBh12sEK1bheYPwm2U9ikP9GxZUPzPNj
Swarm listening on /ip4/127.0.0.1/tcp/4003/ws/p2p/12D3KooWSZy8uChn5WRNyBh12sEK1bheYPwm2U9ikP9GxZUPzPNj
Checking on-chain database: ipdb_rocks_1661516338036
On-chain version is: 0
Root path exists..
Need to create database..
Creating new database at: /0x5d0a965E6e8388fd39D897c2B2EED5c3074421d6/ipdb_rocks_1661516338036/0
Contents are: {}
--
`rocks` value is: true
--
`power` value is: 100
--
Informations about db are: {
  cid: CID(bafybeicdq2w4ulz72x7tli6qoyjjwtj7tyxzvngzk6kedhza3bydxrgpj4),
  type: 'file',
  size: 26,
  cumulativeSize: 99,
  blocks: 1,
  local: undefined,
  sizeLocal: undefined,
  withLocality: false,
  mode: 420,
  mtime: { secs: 1661516344, nsecs: 371000 }
}
--
Storing DB: ipdb_rocks_1661516338036
CID is: bafkreifzd53l5ko3l77hxofxwyq4niw2uudw3g7xop32kufznwnsamlss4
Storing database with new version at: /db1x5d0a965E6e8388fd39D897c2B2EED5c3074421d6/ipdb_rocks_1661516338036/0
Pending transaction at: 0x72e5b573820434af206c791bb0d9aa61b3428dcadbcaabe88eb2f1d46b6093fb
💸 Gas used: 139237
Db stored successfully!

Done! As you can see we created a database that contains two keys (rocks and power) and the final CID is QmXL26iGZ3MCAkpKnoBRpbc4oHH95nmjYF48FRWLYfk7Yv. You can continue manipulate the database also if you close the terminal and use correct dbid to open it.

You can try other tests that will help you understand better how this library works.

What about blockchain?

As you may noticed at the very beginning of the test there's this piece of code:

const provider = new ipdb.ethers.providers.JsonRpcProvider("https://goerli.infura.io/v3/" + process.env.INFURA_PROJECT_ID);
ipdb.wallet = new ipdb.ethers.Wallet(process.env.OWNER_KEY).connect(provider)

This means the database you must create a wallet or use a key you've in your .env file to instantiate the database. Otherwise it will not be able to store or retrieve databases.

Deployments

Contracts are deployed in following blockchains:

Blockchain Address
Rinkeby 0xC1755f486Fa83912a94b0A1904e74722d557AB0b
Goerli 0xB4E1E4C194972703f9ecfeaB396B3B6aaccd52Ab
tAurora 0x1Aa65998a6751464FACD2f62Fa28e5B0034496ca
Mumbai 0x1Aa65998a6751464FACD2f62Fa28e5B0034496ca

Default blockchain is Goerli but you can switch from Goerli to Rinkeby like this:

const ipdb = new IPDB()
ipdb.blockchain = 'rinkeby'

or you can also define your own custom smart contract like this:

const ipdb = new IPDB()
ipdb.deployments.custom = '0x00000000000000YourOwnCustomSmartContract'
ipdb.blockchain = 'custom'

Functions

Main examples can be read inside tests folder, anyway there's a recap of all functions:

create(name)

This function will create a new local instance of a database called name, this returns an id and the db itself which can be read or populated.

retrieve(name)

This function will retrieve latest version of database from blockchain in form of CID and will create a local copy on your machine, so you can interact with it very fast.

put(id, content)

This function will put specified content inside database provided by id parameter. The id database must exists inside the machine because was created or retrieved before.

get(id, key)

This function will return value of specified key from id.

stats(id)

This function will return the informations about the database.

store(id)

This function will store specified database's CID into the blockchain. At the moment the only support blockchain is Goerli, so make sure you have some funds to store the database or the transaction will fail.

set(provider, jwt)

This function will prepare the remote pinning provider, supported one are pinata and web3storage. Please remember to add JWT tokens in your .env file.

pin(id, provider)

This function will make a remote pinning of specified id to provider.

TODO list

If you want to help doing some stuff you can follow this list or write me at [email protected] or DM me on Twitter.

  • Switch to CID v1
  • Add tests to contract folder
  • Add a .env file to select the contract and add pinning services token
  • Add a web3.storage and nft.storage pinning system
  • Add PubSub support to exchange data between nodes
  • Create a website for the project
  • Publish version to NPM
  • Create a pitch to explain the project
  • Create a Twitter account to make some marketing on it

Use cases

  • Dynamic NFT use case
  • Decentralized git use case: each database can represent git folders, each git folder contains files, each file is hashed and uploaded as well
  • The "Google's IPFS" use case: a collaborative repository of data where anyone can publish formatted metadatas (needs an oracle)
You might also like...

chain-syncer is a module which allows you to synchronize your app with any ethereum-compatible blockchain/contract state. Fast. Realtime. Reliable.

Chain Syncer Chain Syncer is a JS module which allows you to synchronize your app with any ethereum-compatible blockchain/contract state. Fast. Realti

Dec 15, 2022

An Ethereum-compatible blockchain with a giant capacity for storage

goliath The Goliath blockchain is an Ethereum L2 with a giant capacity. For devs, it means you'll never need another chain. No bridges, no new languag

Dec 23, 2022

NFT sales monitoring bot for the Ethereum blockchain. (ERC721, ERC1155)

NFT sales monitoring bot for the Ethereum blockchain. (ERC721, ERC1155)

Ethereum-NFT-Sales-Bot NFT sales monitoring bot for the Ethereum blockchain. (erc721, erc1155) Table of Contents Click to expand Market Coverage GIF G

Dec 13, 2022

🤑💰 Crowdfunding Platform backed by Ethereum Blockchain to bring your creative projects to life

🤑💰 Crowdfunding Platform backed by Ethereum Blockchain to bring your creative projects to life

Crypto Crowdfund For Creators Lacking the money to bring your Creative Venture to Life? Crypto Crowdfund Campaigns will help you turn your creative id

Oct 3, 2022

A lightweight, performant, and simple-to-use wrapper component to stick section headers to the top when scrolling brings them to top

A lightweight, performant, and simple-to-use wrapper component to stick section headers to the top when scrolling brings them to top

Jun 27, 2022

Solana blockchain candy machine app boilerplate on top of Metaplex Candy Machine. NextJS, Tailwind, Anchor, SolanaLabs.React, dev/mainnet automation scripts.

NFT Candy Factory NOTE: This repo will prob only work on unix-based environments. The NFT Candy Factory project is designed to let users fork, customi

Dec 30, 2022

HackMIT 2022. 2nd Place in Blockchain for Society sponsored by Jump Crypto. A revolutionary web application that leverages machine learning and blockchain technology to improve the crowdsourcing experience!

HackMIT 2022. 2nd Place in Blockchain for Society sponsored by Jump Crypto. A revolutionary web application that leverages machine learning and blockchain technology to improve the crowdsourcing experience!

📕 Wikisafe 📕 Wikisafe is a revolutionary new crowdsourcing web application that innovates the process of crowdsourcing information. This application

Dec 8, 2022

Proof of concept: support immutable trpc servers using lambdas to ensure client/server compatibility

auto-versioned-trpc-aws-lambda Proof of concept to support an automatically versioned AWS Lambda running tRPC to ensure a somewhat graceful and automa

Aug 30, 2022

It is a very basic implementation of how blockchain works, mainly how the bitcoin blockchain.

How to run this program npm install node core/blockchain.js What is this It is a very basic implementation of how blockchain works, mainly how the bit

May 9, 2022
Owner
turinglabs
Polyhedric blockchain developer | YOMI // Protocol Labs contributor // Quadrans Foundation Member
turinglabs
📦 Fully typed and immutable store made on top of Immer with mutation, action, subscription and validation!

Riux is a fully typed and immutable store made on top of Immer with mutation, action, subscription and validation! Table of contents ?? Installation U

null 10 Aug 27, 2022
Decentralized twitter using Solidity, Ethereum, hardhat, ethers, IPFS, Next.JS, TypeScript, TailwindCSS.

DWITTER: Decentralized Twitter Check out the deployed version of this app at https://dwtr.wajeshubham.in Transactions on Ethereum are slow. Therefore,

Shubham Waje 12 Sep 2, 2022
✨ An IRL tokenization platform to turn your hopes, dreams, and desires into fundable NFTs on the Polygon blockchain using Chainlink, IPFS, Moralis, and NFT.Storage.

GoFundYourself Getting funding for your passion project, needs or dream doesn't have to be a nightmare! check out our live demo on Netlify Let's Fundi

Brian H. Hough | brianhuff.eth 7 Dec 6, 2022
ChainLook is a decentralized blockchain analytics platform based on TheGraph and IPFS.

ChainLook https://chainlook.xyz ChainLook is a decentralized blockchain analytics platform based on TheGraph and IPFS. You can create beautiful widget

Saleel 11 Nov 21, 2022
A messaging app built on top of Solana blockchain where you can store and view your messages.

Message App on Solana ?? This Message application written Rust using Anchor âš“ Setting up the Environment: Rust Installation curl --proto '=https' --tl

Ritesh 10 Oct 2, 2022
Using a Decentralized Application (DApp) to Sell artwork on the Ethereum blockchain with smart contracts written in Solidity.

Decentralized Applications For Selling Limited Time Artwork This repository houses the Solidity, JavaScript, and HTML code for a Decentralized Applica

Keyan Ahmadi 4 Mar 20, 2023
Your Ethereum control panel. Interact with smart contracts on Ethereum.

etherfunk Your Ethereum control panel. Interact with smart contracts on Ethereum. ?? https://etherfunk.io ?? Devleopment First, run the development se

Tom Quirk 23 Sep 24, 2022
A comprehensive collection of useful tools developed with the help of Ethers.js to interact with the Ethereum Blockchain to develop great DeFi apps as quickly and easily as possible.

hudi-packages-ethersfactory How to install Installing with npm For more information on using npm check out the docs here. npm i @humandataincome/ether

HUDI 6 Mar 30, 2022
A small and simple stress testing tool for Ethereum-compatible blockchain networks

Overview pandoras-box is a small transaction stress testing tool, part of any Ethereum client developer's toolkit. It is made for Ethereum-compatible

Trapesys 6 Aug 30, 2022
Multi-sig wallet for the Ethereum blockchain.

Ethereum Multi-sig Wallet See it live here Prerequisites Follow this guide to create an Ethereum wallet and switch to the Rinkeby Test Network Send yo

Spencer Miller 8 Feb 26, 2022