在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:saurfang/ipfs-multihash-on-solidity开源软件地址:https://github.com/saurfang/ipfs-multihash-on-solidity开源编程语言:JavaScript 70.2%开源软件介绍:IPFS hash (multihash) with Solidity and web3.jsExample of using Solidity and web3.js to store and retrieve IPFS hash and more generally multihash. IPFS hash is often represented using 46 character long Base58 encoding(e.g. However this can be both expensive and challenging to use IPFS hashes in arrays. Luckily as one might notice that IPFS hashes commonly start with
This makes it possible to break down IPFS hash into a struct like so: struct Multihash {
bytes32 digest;
uint8 hashFunction;
uint8 size;
} This repository gives an end-to-end example on how to store IPFS hash in Solidity as well as how to call the smart contract using web3.js to get and set IPFS hash. IPFSStorage.sol is a smart contract that stores IPFS hash in a mapping from address key to Multihash struct. Because web3.js ABI doesn't support passing tuple as parameter and return type, additional care is taken to normalize the function interface to be web3.js friendly. multihash.js contains the Javascript code that converts base58 encoded multihash string to and from smart contract friendly arguments and responses. Refer to test cases for additional example code how to interact with the contract. ReferenceMultihash Format: https://github.com/multiformats/multihash zeppelin-solidity for project setup and test helpers. Previous discussions and examples: How to store IPFS hash using bytes? A practical guide to cheap IPFS hash storage in an Ethereum smart contract |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论