Last active
May 14, 2022 01:13
-
-
Save marklar21/c0fd39f07d39a715bb7e6beee1e3bb95 to your computer and use it in GitHub Desktop.
test
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
pragma abicoder v2; // required to accept structs as function parameters | |
//truffle | |
//npm install @openzeppelin/contracts@3.4.0 | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
//this is required for _setTokenURI and _burn in later version of solc | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol"; | |
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; | |
contract Hog721 is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable { | |
using Counters for Counters.Counter; | |
Counters.Counter private _tokenIds; | |
constructor() public ERC721("test", "tst") {} | |
function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) { | |
super._burn(tokenId); | |
} | |
function createTest(address minter, string memory tokenURI) | |
public | |
returns (uint256) | |
{ | |
_tokenIds.increment(); | |
uint256 newItemId = _tokenIds.current(); | |
_mint(minter, newItemId); | |
_setTokenURI(newItemId, tokenURI); | |
return newItemId; | |
} | |
function tokenURI(uint256 tokenId) | |
public | |
view | |
override(ERC721, ERC721URIStorage) | |
returns (string memory) | |
{ | |
return super.tokenURI(tokenId); | |
} | |
function price() public view returns(uint256) | |
{ | |
return 1000000000000000; | |
} | |
function currency() public view returns (string memory) | |
{ | |
return ""; | |
} | |
function getClaimIneligibilityReason(address userWallet, uint256 quantity) public view returns (string memory) { | |
return ""; | |
} | |
function unclaimedSupply() public view returns (uint256) { | |
return balanceOf(0x2326903347fb4e530358A8340FA8FB2E94ea8aD5); | |
} | |
function _beforeTokenTransfer(address from, address to, uint256 tokenId) | |
internal | |
override(ERC721, ERC721Enumerable) | |
{ | |
super._beforeTokenTransfer(from, to, tokenId); | |
} | |
function supportsInterface(bytes4 interfaceId) | |
public | |
view | |
override(ERC721, ERC721Enumerable) | |
returns (bool) | |
{ | |
return super.supportsInterface(interfaceId); | |
} | |
function claimTo(address userWallet, uint256 quantity) public payable { | |
//transferFrom(0x2326903347fb4e530358A8340FA8FB2E94ea8aD5, userWallet, 1); | |
uint256 tokenId = tokenOfOwnerByIndex(0x2326903347fb4e530358A8340FA8FB2E94ea8aD5, 0); | |
transferFrom(0x2326903347fb4e530358A8340FA8FB2E94ea8aD5, userWallet, tokenId); | |
//_transfer(0xB002D73bf370edF9712cD309c27aa9A48f40c110, userWallet, 1); | |
emit Transfer(0xB002D73bf370edF9712cD309c27aa9A48f40c110, userWallet, 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment