Skip to content

Instantly share code, notes, and snippets.

@fassko
Last active March 28, 2024 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fassko/f244139e246091225ecfebc2e77984b7 to your computer and use it in GitHub Desktop.
Save fassko/f244139e246091225ecfebc2e77984b7 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.25+commit.b61c2a91.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "hardhat/console.sol";
contract Snowflake is ERC721 {
uint256 private _nextTokenId;
constructor() ERC721("Snowflake", "SFLK") {}
function safeMint(address to) public {
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
}
// Send to ESCROW address
function sendToESCROW(address escrow, uint256 tokenId) public {
approve(escrow, tokenId);
}
// Returns the ESCROW address
// 0x address means that this NFT has not been sent to ESCROW
function isSentToESCROW(uint256 tokenId) public view returns(address) {
return _getApproved(tokenId);
}
// Remove from ESCROW
function removeFromESCROW(uint256 tokenId) public {
approve(address(0), tokenId);
}
// Transfer to new owner from ESCROW
function transferFromEscrow(uint256 tokenId, address from, address to) public {
safeTransferFrom(from, to, tokenId);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment