Created
October 27, 2021 20:56
-
-
Save soenkeba/5df8ee90d600e8e3c9ceee0a6a3a23a0 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; | |
contract sciencefaction is ERC1155 { | |
uint256 public constant DECENTRAFISH = 0x01559ae4021a4dcafee8abc36a5139b96d58cbba2fe6cd347c4ed6668011aac5; | |
uint256 public constant NFThistory = 0x01559ae4021a99b0d373d7bc8a80504bad782367abe12c21373c83adc6bf6a7e; | |
uint256 public constant IPFSforscher = 0x01559ae4021a9c84fa506cb76691054c2b92f655222cde2437d77ed21c083c4d; | |
constructor() public ERC1155("ipfs://f0{id}") { | |
_mint(msg.sender, DECENTRAFISH, 1, ""); | |
_mint(msg.sender, NFThistory, 1, ""); | |
_mint(msg.sender, IPFSforscher, 1, ""); | |
} | |
function mint( | |
address to, | |
uint256 id, | |
uint256 amount, | |
bytes memory data | |
) public virtual { | |
_mint(msg.sender, id, amount, data); | |
} | |
function uint2hexstr(uint256 i) public pure returns (string memory) { | |
if (i == 0) return "0"; | |
uint j = i; | |
uint length; | |
while (j != 0) { | |
length++; | |
j = j >> 4; | |
} | |
uint mask = 15; | |
bytes memory bstr = new bytes(length); | |
uint k = length; | |
while (i != 0) { | |
uint curr = (i & mask); | |
bstr[--k] = curr > 9 ? | |
bytes1(uint8(55 + curr)) : | |
bytes1(uint8(48 + curr)); // 55 = 65 - 10 | |
i = i >> 4; | |
} | |
return string(bstr); | |
} | |
function uri(uint256 _tokenID) override public view returns (string memory) { | |
string memory hexstringtokenID; | |
hexstringtokenID = uint2hexstr(_tokenID); | |
return string( | |
abi.encodePacked( | |
"ipfs://f0", | |
hexstringtokenID) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@chrisalmeida here is example how you can get v1 CID
https://gist.github.com/tarassh/5d4f0bf32288771e9a5679da0bd82ac6