我怎样才能让令牌客户访问一堆不在区块链上的文件? (以太坊)

How can I give Token-Customers access to a bunch of files that are not on the Blockchain? (Ethereum)

起初我只想让他们看到一个 Google 驱动器 link 但那必须保持不变,这样客户就可以互相发送 link ,即使人们必须使用智能合约才能获得它。

您可以使用 https://ipfs.io(分布式文件存储)和以太坊 DApp 来解决这个问题。鉴于您提到您希望人们使用智能合约来访问文件,我认为您需要在存储到 IPFS 之前加密文件。因为 IPFS 是分布式的,所以任何人都可以在知道文件存在的情况下获取该文件,但只有有权访问私钥的人才能读取它。

当满足智能合约的条件时,您可以释放密钥。因为以太坊智能合约无法进行实际解密,所以您的 web3 应用程序需要完成这部分工作。

例如在web3 app中将文件存储到IPFS后:

addNewFile: function() {
    // encrypt the file
    var encryptedFile = CryptoJS.AES.encrypt(fileData, passPhrase);
    // store on the IPFS
    ipfs.files.write( ... => {
        // make sure it worked
        ...
        // (fileName is an IPFS-generated hash uniquely identifying the (encrypted) file
        // write it to the contract
        deployedFileContract.AddFileEntry(fileLocation, fileName, passPhrase, function(error) {
            // respond to error condition
        });
    });
};

retrieveEncyptedFile: function() { 
    ...
    deployedFileContract.RetrieveFileEntry.call(_pointer-to-file_, function(error, result) {
        // fetch an encrypted file as a readable stream from IPFS

        // decrypt it and probably do something funky with mime types to make sure it gets saved
        var decryptedFile =  CryptoJS.AES.decrypt(encryptedFileStream, passPhrase). ...

    });
...
};

总而言之,您将需要您的 Solidity 智能合约和一个 web3 应用程序。您可以在浏览器中 运行 IPFS js-client https://github.com/ipfs/js-ipfs,或者通过 Nodejs 或 Go 访问它。