Created
October 27, 2021 22:47
-
-
Save soenkeba/c7ddf262c370f099a6256a9a76832dbe 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 payable { | |
require(msg.value >= 2, "Not enough ETH sent; check price!"); | |
_mint(msg.sender, id, amount, data); | |
} | |
// Function to withdraw all Ether from this contract. | |
function withdraw() public { | |
// get the amount of Ether stored in this contract | |
uint amount = address(this).balance; | |
// send all Ether to owner | |
// Owner can receive Ether since the address of owner is payable | |
(bool success, ) = owner.call{value: amount}(""); | |
require(success, "Failed to send Ether"); | |
} | |
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