Skip to content

Instantly share code, notes, and snippets.

@bet02024
Created December 21, 2020 17:54
Show Gist options
  • Save bet02024/979e5d19558840ccac2ccbe5ddef029d to your computer and use it in GitHub Desktop.
Save bet02024/979e5d19558840ccac2ccbe5ddef029d 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.6.12+commit.27d51765.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0/contracts/token/ERC721/ERC721.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0/contracts/token/ERC721/ERC721Burnable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0/contracts/token/ERC721/ERC721Pausable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v3.2.0/contracts/token/ERC721/ERC721Holder.sol";
import './Ownable.sol';
contract M2Coin is ERC721, ERC721Burnable, ERC721Holder, Ownable {
//mapping (uint256 => string) private _tokenJson;
//mapping(address => bool) internal minters;
//mapping(address => uint256) internal minterAllowed;
//event Mint(address indexed minter, address indexed to, uint256 amount);
//event Burn(address indexed burner, uint256 amount);
constructor (string memory name, string memory symbol) public ERC721(name, symbol){
_name = name;
_symbol = symbol;
}
string private _name;
string private _symbol;
bool internal initialized;
mapping(address => bool) internal minters;
modifier onlyMinters() {
require(minters[msg.sender] == true);
_;
}
function initialize(
string memory name,
string memory symbol,
address _owner
) public {
require(!initialized);
require(_owner != address(0));
_name = name;
_symbol = symbol;
setOwner(_owner);
initialized = true;
}
function isMinter(address account) public view returns (bool) {
return minters[account];
}
function configureMinter(address minter) public onlyOwner returns (bool) {
minters[minter] = true;
return true;
}
function removeMinter(address minter) public onlyOwner returns (bool) {
minters[minter] = false;
return true;
}
function mintTokensWithTokenURI(address to, uint256 totalTokens, string memory tokenURI) public onlyMinters returns (bool) {
uint256 currentTokens = totalSupply();
for (uint256 tokenId = currentTokens + 1; tokenId <= currentTokens + totalTokens + 1; tokenId++) {
_safeMint(to, tokenId, "");
_setTokenURI(tokenId, tokenURI);
}
return true;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @title Ownable
* @dev The Ownable contract from https://github.com/zeppelinos/labs/blob/master/upgradeability_ownership/contracts/ownership/Ownable.sol
* branch: master commit: 3887ab77b8adafba4a26ace002f3a684c1a3388b modified to:
* 1) Add emit prefix to OwnershipTransferred event (7/13/18)
* 2) Replace constructor with constructor syntax (7/13/18)
* 3) consolidate OwnableStorage into this contract
*/
contract Ownable {
// Owner of the contract
address private _owner;
/**
* @dev Event to show ownership has been transferred
* @param previousOwner representing the address of the previous owner
* @param newOwner representing the address of the new owner
*/
event OwnershipTransferred(address previousOwner, address newOwner);
/**
* @dev The constructor sets the original owner of the contract to the sender account.
*/
constructor() public {
setOwner(msg.sender);
}
/**
* @dev Tells the address of the owner
* @return the address of the owner
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Sets a new owner address
*/
function setOwner(address newOwner) internal {
_owner = newOwner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner());
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner(), newOwner);
setOwner(newOwner);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment