import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/ipfs/IPFS.sol";
this file does not exist, how do i access IPFS?
Code to reproduce
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/ipfs/IPFS.sol";
this file does not exist, how do i access IPFS?
Hi,
I'm sorry to inform you that we do not have an IPFS contract. May I ask where you obtained the link from? Furthermore, could you please specify what were you trying to do?
ChatGPT gave me that link.
trying to build a dex that stores the order book on IPFS
address public owner;
IPFS public ipfs;
mapping (address => mapping (address => uint256)) public orderBook;
mapping (address => mapping (address => uint256)) public orderPrices;
mapping (address => bool) public tokens;
mapping (address => bool) public operators;
event TokenListed(address token, address pairToken, uint256 price);
event OrderPlaced(address token, uint256 price, uint256 amount);
event OrderCancelled(address token, uint256 price, uint256 amount);
event OrderFilled(address token, uint256 price, uint256 amount);
constructor() public {
owner = msg.sender;
ipfs = new IPFS();
}
I'ts important to acknowledge that chatGPT can be wrong sometimes, so I wouldn't rely entirely on their answers, so make sure to always cross check what it says.
In the contract you provided IPFS
is most likely a reference to a custom smart contract or an imported library that provides IPFS-related functionality. But that is not part of the Openzeppelin/contracts library.
If what you want is "to build a dex that stores the order book on IPFS" the uploading part could be done outside the contract, as shown on this article, and store the IPFs hash in the contract, I would suggest using ERC721URIStorage because it comes with a mapping of tokenId
to string
where you could store the ipfs url to each book minted.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract BookStore is ERC721, ERC721URIStorage, Ownable {
constructor() ERC721("BookStore", "MBK") {}
// The following functions are overrides required by Solidity.
function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
super._burn(tokenId);
}
function createBook(uint256 tokenId, string memory url) public onlyOwner {
_mint(msg.sender, tokenId);
_setTokenURI(tokenId, url);
}
...
function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}
}
As you can see when the owner creates a book by calling createBook
it can set a tokenUrl, in your case that will be an ipfs link to your token/book.