The-Graph
獲取 IPFS 數據 Subgraph Studio 不支持使用 ipfs 方法的映射
我正在使用該圖表,並希望在傳輸事件中通過 ipfs 獲取 NFT 元數據。除非我嘗試通過 ipfs 獲取元數據,否則一切都按預期工作
架構看起來像
type Example @entity { id: ID! createdAtTimeStamp: BigInt! contentURI: String! tokenId: BigInt! name: String! description: String! image: String! externalURL: String! }
和轉會事件
const IPFSHASH = "EXAMPLE_IPFS_HASH"; export function handleTransfer(event: TransferEvent): void { let example = Example.load(event.params.tokenId.toString()); if (!example) { example = new Example(event.params.tokenId.toString()); example.createdAtTimeStamp = event.block.timestamp; example.tokenId = event.params.tokenId; let exampleContract = ExampleContract.bind(event.address); example.contentURI = exampleContract.tokenURI(event.params.tokenId); const ipfsUrl = "/" + event.params.tokenId.toString() + ".json"; let metadata = ipfs.cat(ipfshash + token.tokenURI); if(metadata) { ..... } }
每當我使用圖中的 ipfs lib 時出現錯誤,我都無法正確編譯它
Failed to compile data source mapping: Subgraph Studio does not support mappings with ipfs methods.
根據文件,Graph Network 尚不支持 ipfs.cat 和 ipfs.map,開發人員不應通過 Studio 將使用該功能的子圖部署到網路。
請參閱:https ://thegraph.com/docs/en/developing/creating-a-subgraph/