【问题标题】:Does chainlink have a reliable way to verify the size/format of a file behind a hash stored on IPFS?chainlink 是否有可靠的方法来验证存储在 IPFS 上的哈希后面的文件的大小/格式?
【发布时间】:2021-07-22 01:14:00
【问题描述】:

我们的想法是使用像 Chainlink 这样的区块链 Oracle,以一种分布式方式从 Solidity 智能合约中检索存在、字节大小和文件格式:

存储在 IPFS 上的图像示例:https://ipfs.io/ipfs/QmYjh5NsDc6LwU3394NbB42WpQbGVsueVSBmod5WACvpte

import "@chainlink/contracts/src/v***/IPFSConsumer.sol";

contract VerifyFile is IPFSConsumer {
    // hashIPFS: QmYjh5NsDc6LwU3394NbB42WpQbGVsueVSBmod5WACvpte
    function verify(bytes32 hashIPFS) public returns (bool, uint256, string) {
         bytes32 requestId = IPFSmetadata(hashIPFS);
         // ... fulfill request with requestId
    }
}

import "@chainlink/contracts/src/v***/IPFSInterface.sol";

contract VerifyFile {
    IPFSInterface internal IPFSmetadata
    
    // hashIPFS: QmYjh5NsDc6LwU3394NbB42WpQbGVsueVSBmod5WACvpte
    function verify(bytes32 hashIPFS) public returns (bool, uint256, string) {
         (bool exists, uint256 size, string format) = IPFSmetadata.fromHash(hashIPFS);
         return ...
    }
}

【问题讨论】:

    标签: blockchain ethereum ipfs chainlink


    【解决方案1】:

    TL;DR: 有了Chainlink,如果你能写出一个能做到的程序,你就能做到。


    更长的答案: 这是IPFS chainlink external adapter.的概念证明

    您想要做的是将您的合约连接到具有以下工作的节点:

    1. 从你的合约调用 IPFS API
    2. 从哈希中返回文件的大小。

    是的,这是可能的。不,以前没有人这样做过。你会是第一个。 Here is more information on building and using external adapters.

    【讨论】:

      猜你喜欢
      • 2015-10-12
      • 1970-01-01
      • 2022-08-17
      • 1970-01-01
      • 2015-11-07
      • 2020-11-17
      • 2016-11-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多