当前位置: 首页 > 软件库 > Web3 > 区块链 >

ipfs-eth-database

授权协议 Readme
开发语言
所属分类 Web3、 区块链
软件类型 开源软件
地区 不详
投 递 者 邹英发
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

IPFS in Ethereum Smart Contracts

This is a simple blog application that is a proof of concept of connecting Ethereum's smart contracts to JSON database stored on IPFS. The communication is based on Oraclize service.

How to run?

Prepare a blog contract

First you have to deploy a contract.

Here is an example how to deploy to Rinkeby testnet via infura node.

Set your mnemonic in wallet-config.json.

Run migrations:

 truffle migrate --network rinkeby-infura --reset

You should see the address of the contract:

Blog: 0x461192ab19b0a963a77fdc8dea5ee9ac4287ff31

We have to set this address in app/blog/config/blog.json file.

Install IPFS

You have to have your own IPFS node that will store the database. Installation process is described here.

After installation we can run the daemon:

ipfs daemon

Run the server

Install npm dependencies:

npm install

and run the server

./node_modules/.bin/parcel app/index.html

Prepare blogposts

Each blogpost is stored in JSON object that consists of two attributes: title and content.

Let's prepare two blogposts.

echo '{"title":"Title of the first post", "content": "This is the awesome content!"}' > post_1.json
echo '{"title":"Title of the second post", "content": "This is the most awesome content!"}' > post_2.json

And we have to add them to IPFS as follows:

ipfs add post_1.json; ipfs add post_2.json

You should see two hashes (addresses) of the files:

added QmU2yr8CQfrd26Yghjx2xGdg8ZdmRKRSwcD7eBgpvL91xf post_1.json
added QmRPdMo8HEoSWSPXg1NxvLPcDNdL7YocvhXdYHjGQaXmfC post_2.json

You should be able to read the files by ipfs cat command or by a public gateway:

ipfs cat QmU2yr8CQfrd26Yghjx2xGdg8ZdmRKRSwcD7eBgpvL91xf

{"title":"Title of the first post", "content": "This is the awesome content!"}
curl http://ipfs.io/ipfs/QmU2yr8CQfrd26Yghjx2xGdg8ZdmRKRSwcD7eBgpvL91xf

{"title":"Title of the first post", "content": "This is the awesome content!"}

Keep the hashes for the next step.

Now we can add our blogposts using following command:

node scripts/add-blog-post.js <FILE_ADDRESS>

In our case:

node scripts/add-blog-post.js QmU2yr8CQfrd26Yghjx2xGdg8ZdmRKRSwcD7eBgpvL91xf
node scripts/add-blog-post.js QmRPdMo8HEoSWSPXg1NxvLPcDNdL7YocvhXdYHjGQaXmfC

Then you should see the link to your blog

Your blog is available here:
http://localhost:1234/#/u/0x351944e0d307d536737de4c6f07382548437fb53

Now we can open the link above and check if our blog works properly.

  • 如何将JSON文件存储在IPFS上,并使用Oraclize访问智能合约中的数据呢? 以太坊是一个成熟的区块链,使开发人员能够创建智能合约,在区块链上执行的程序可以由交易触发。人们经常将区块链称为数据库,但使用区块链作为数据存储非常昂贵。 以目前的价格(530美元,4gwei)在以太坊上存储250GB将花费你106,000,000美元。一般来说,我们可以忍受高成本因为我们: 不会在以太坊区块链上保存

  • 如何将JSON文件存储在IPFS上,并使用Oraclize访问智能合约中的数据呢? 以太坊是一个成熟的区块链,使开发人员能够创建智能合约,在区块链上执行的程序可以由交易触发。人们经常将区块链称为数据库,但使用区块链作为数据存储非常昂贵。 以目前的价格(530美元,4gwei)在以太坊上存储250GB将花费你106,000,000美元。一般来说,我们可以忍受高成本因为我们: 不会在以太坊区块链上保存

 相关资料
  • IPFS 是分布式文件系统,寻求连接所有计算机设备的相同文件系统。在某些方面,这很类似于原始的 Web 目标,但是 IPFS 最终会更像单个比特流群交换的 git 对象。 IPFS = InterPlanetary File System IPFS 云成为一个新的、重要的网络子系统,如果构建得当,可以完善或者替换 HTTP,或者更多。 IPFS 结合了 Git,BitTorrent,Kademli

  • 包含以太坊区块链相关的方法 示例: var eth = web3.eth;

  • eth-crypto Cryptographic javascript-functions for ethereum and tutorials on how to use them together with web3js and solidity. Tutorials Creating keys and use them for ethereum transactions In this tu

  • gomobile-ipfs This repo aims to provide packages for Android, iOS and React-Native thatallow one to run and use an IPFS node on mobile devices. It is also a placeto discuss the constraints of running

  • 《IPFS与Filecoin 从入门到精通》 在接触 IPFS 之后,对这种可以本质上改变网络数据的分发机制的协议非常感兴趣,但由于目前国内并没有比较深入分析 IPFS 的书籍,而一些资料因为英文的缘故在一定程度上也为不少 IPFS 爱好者带来了一些学习上的困扰,不仅为了加快扩散 IPFS 爱好者的国内群体,决定以开源的形式完成这本《IPFS与Filecoin 从入门到精通》的书籍。 写作进度 开

  • ipfs-deploy Upload static website to IPFS pinning services and optionally update DNS. The goal of ipfs-deploy is to make it as easy as possible to deploy a staticwebsite to IPFS. Install Usage API Con