-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathINO_Drafts.sol
More file actions
85 lines (60 loc) · 2.29 KB
/
INO_Drafts.sol
File metadata and controls
85 lines (60 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// contracts
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
//1
contract cINO is ERC721, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() public ERC721("CHRONSTATE INO", "cINO") {}
function mintNft(string memory tokenURI) public onlyOwner returns (uint256) {
_tokenIds.increment();
uint256 newNftTokenId = _tokenIds.current();
_mint(msg.sender, newNftTokenId);
_setTokenURI(newNftTokenId, tokenURI);
return newNftTokenId;
}
}
contract cNftSale is IERC721Receiver, Ownable {
IERC721 public cINO;
uint256 constant public cost = 0.1 ether;
constructor(IERC721 token) public {
cINO = token;
}
function buyNft(address to, uint256 tokenId) external payable {
require(msg.value == cost);
cINO.safeTransferFrom(address(this), to, tokenId);
}
function withdrawNft(uint256 tokenId) external onlyOwner {
cINO.safeTransferFrom(address(this), owner(), tokenId);
}
function withdrawEth() external onlyOwner {
msg.sender.transfer(address(this).balance);
}
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
require(msg.sender == address(cNft));
return this.onERC721Received.selector;
}
}
//2
contract cNft is ERC721, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
uint256 constant public cost = 0.5 ether;
constructor() public ERC721("CHRONSTATE INO", "cINO") {}
function mintNft(string memory tokenURI) public payable returns (uint256) {
require(msg.value == cost);
_tokenIds.increment();
uint256 newNftTokenId = _tokenIds.current();
_mint(msg.sender, newNftTokenId);
_setTokenURI(newNftTokenId, tokenURI);
return newNftTokenId;
}
function withdrawEth() external onlyOwner {
msg.sender.transfer(address(this).balance);
}
}