在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:tooploox/ipfs-eth-database开源软件地址:https://github.com/tooploox/ipfs-eth-database开源编程语言:Solidity 89.5%开源软件介绍:IPFS in Ethereum Smart ContractsThis 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 contractFirst you have to deploy a contract. Here is an example how to deploy to Rinkeby testnet via infura node. Set your mnemonic in Run migrations:
You should see the address of the contract:
We have to set this address in Install IPFSYou have to have your own IPFS node that will store the database. Installation process is described here. After installation we can run the daemon:
Run the serverInstall npm dependencies:
and run the server ./node_modules/.bin/parcel app/index.html Prepare blogpostsEach 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:
You should be able to read the files by 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:
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
Now we can open the link above and check if our blog works properly. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论