Skip to content

Instantly share code, notes, and snippets.

@staccDOTsol
Created September 26, 2022 17:39
Show Gist options
  • Save staccDOTsol/d170df015d7365d818571163bee3155f to your computer and use it in GitHub Desktop.
Save staccDOTsol/d170df015d7365d818571163bee3155f to your computer and use it in GitHub Desktop.
erc721 custom
//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract StaccStaccs is ERC721URIStorage, Ownable {
using Counters for Counters.Counter;
string [] private staccs = [""];
Counters.Counter private _tokenIds;
Counters.Counter private _staccIds;
Counters.Counter private _burned;
mapping (uint256 => uint256) claimed;
address stacc1 = 0xbA3602F1ef448EDe2d057b6a3E9E371Ae02f02D6;
address stacc2 = 0xbA3602F1ef448EDe2d057b6a3E9E371Ae02f02D6;
string private ipfs = "ipfs://";
uint256 length = 50;
uint256 endts;
uint256 endts2 = block.timestamp;// + 86400 * 7
uint256 price = 50000;
uint256 base = 10000;
uint256 increment = 3;
constructor(string memory _name, string memory _ticker, uint256 _length, uint256 _price, uint256 _base, string [] memory _staccs, uint256 _increment) ERC721(_name, _ticker) {
staccs = staccs;
length = _length;
price = _price;
base = _base;
staccs = _staccs;
increment = _increment;
}
function testInProd()
public
onlyOwner
returns (uint256) {
endts = block.timestamp + 86400 * 1;
return endts;
}
function twophase()
view
public
returns (uint256) {
return endts;
}
function totalSupply()
view
public
returns (uint256) {
return _tokenIds.current() - _burned.current();
}
function x()
view
public
returns (uint256) {
return _tokenIds.current();
}
function getBalance() public view returns (uint) {
return address(this).balance;
}
function getPrice() public view returns (uint) {
return price;
}
function burn(uint256 tokenId)
public
{
require(_isApprovedOrOwner(msg.sender, tokenId));
_burn(tokenId);
_burned.increment();
msg.sender.call{value: getBalance() / 10 }("");
price = price - (base * (_tokenIds.current() + (increment - 1)));
}
function claim(uint256 tokenId)
public
{
require(_isApprovedOrOwner(msg.sender, tokenId));
require(claimed[tokenId] < block.timestamp );
claimed[tokenId] = block.timestamp + 86400 * 1;
msg.sender.call{value: getBalance() / 100 }("");
}
function staccAddies(address _stacc1, address _stacc2)
public
onlyOwner
returns (uint256)
{
stacc1 = _stacc1;
stacc2 = _stacc2;
return 1;
}
function w(address payable _stacc1, address payable _stacc2, uint256 _a1, uint256 _a2)
public
onlyOwner
returns (uint256)
{
require(_a1+_a2 < getBalance() / 10 * 4); // bro there needs to be trailing 0 on balance bro
require(endts2 < block.timestamp);
require (_stacc1 == stacc1, "jare or bust");
require (_stacc2 == stacc2, "jare or bust");
(bool s1, bytes memory data1) = _stacc1.call{value: _a1}("");
require(s1, "Failed to send s1");
(bool s2, bytes memory data2) = _stacc2.call{value: _a2}("");
require(s2, "Failed to send s2");
endts2 = block.timestamp + 86400 * 7;
return 1;
}
function staccMint(address recipient)
public
onlyOwner
returns (uint256)
{
_staccIds.increment();
if (_staccIds.current() > length){
_staccIds.reset();
}
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(recipient, newItemId);
_setTokenURI(newItemId, staccs[_staccIds.current()]);
price = price + (base * (_tokenIds.current() + increment));
claimed[newItemId] = block.timestamp + 86400 * 1;
return newItemId;
}
function mintNFT(address recipient, address payable ref,address payable _toJare, address payable _stacc2)
public
payable
returns (uint256)
{
require (_toJare == stacc1, "@staccoverflow or bust");
require (_stacc2 == stacc2, "@staccoverflow or bust");
if (msg.value >= price - (base * (_tokenIds.current() + 1)) ){
_staccIds.increment();
if (_staccIds.current() > length){
_staccIds.reset();
}
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(recipient, newItemId);
_setTokenURI(newItemId, staccs[_staccIds.current()]);
claimed[newItemId] = block.timestamp;// + 86400 * 1;
if (block.timestamp <= endts ){
_staccIds.increment();
if (_staccIds.current() > length){
_staccIds.reset();
}
_tokenIds.increment();
price = price + (base * (_tokenIds.current() + increment));
newItemId = _tokenIds.current();
_mint(recipient, newItemId);
claimed[newItemId] = block.timestamp;// + 86400 * 1;
_setTokenURI(newItemId, staccs[_staccIds.current()]);
}
price = price + (base * (_tokenIds.current() + increment));
ref.call{value: msg.value/10}("");
_toJare.call{value: msg.value/10}("");
_stacc2.call{value: msg.value/10}("");
// require(ref, "Failed to send refeth");
return newItemId;
}
else {
revert();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment