Skip to content

Commit eff0f9a

Browse files
committed
inital commit
1 parent a297020 commit eff0f9a

17 files changed

+42023
-96
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = 0
14+
trim_trailing_whitespace = false

.env.sample

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PRIVATE_KEY=
2+
CMC_KEY=

.gitignore

+29-94
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,39 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
lerna-debug.log*
8-
9-
# Diagnostic reports (https://nodejs.org/api/report.html)
10-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11-
12-
# Runtime data
13-
pids
14-
*.pid
15-
*.seed
16-
*.pid.lock
17-
18-
# Directory for instrumented libs generated by jscoverage/JSCover
19-
lib-cov
20-
21-
# Coverage directory used by tools like istanbul
22-
coverage
23-
*.lcov
24-
25-
# nyc test coverage
26-
.nyc_output
27-
28-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29-
.grunt
30-
31-
# Bower dependency directory (https://bower.io/)
32-
bower_components
33-
34-
# node-waf configuration
35-
.lock-wscript
36-
37-
# Compiled binary addons (https://nodejs.org/api/addons.html)
38-
build/Release
39-
40-
# Dependency directories
41-
node_modules/
42-
jspm_packages/
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
432

44-
# TypeScript v1 declaration files
45-
typings/
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
467

47-
# TypeScript cache
48-
*.tsbuildinfo
8+
# testing
9+
/coverage
4910

50-
# Optional npm cache directory
51-
.npm
11+
# next.js
12+
/.next/
13+
/out/
5214

53-
# Optional eslint cache
54-
.eslintcache
15+
# production
16+
/build
5517

56-
# Microbundle cache
57-
.rpt2_cache/
58-
.rts2_cache_cjs/
59-
.rts2_cache_es/
60-
.rts2_cache_umd/
61-
62-
# Optional REPL history
63-
.node_repl_history
64-
65-
# Output of 'npm pack'
66-
*.tgz
67-
68-
# Yarn Integrity file
69-
.yarn-integrity
70-
71-
# dotenv environment variables file
18+
# misc
19+
.DS_Store
20+
*.pem
7221
.env
73-
.env.test
74-
75-
# parcel-bundler cache (https://parceljs.org/)
76-
.cache
77-
78-
# Next.js build output
79-
.next
8022

81-
# Nuxt.js build / generate output
82-
.nuxt
83-
dist
84-
85-
# Gatsby files
86-
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88-
# https://nextjs.org/blog/next-9-1#public-directory-support
89-
# public
90-
91-
# vuepress build output
92-
.vuepress/dist
93-
94-
# Serverless directories
95-
.serverless/
23+
# debug
24+
npm-debug.log*
25+
yarn-debug.log*
26+
yarn-error.log*
9627

97-
# FuseBox cache
98-
.fusebox/
28+
# local env files
29+
.env.local
30+
.env.development.local
31+
.env.test.local
32+
.env.production.local
9933

100-
# DynamoDB Local files
101-
.dynamodb/
34+
# vercel
35+
.vercel
10236

103-
# TernJS port file
104-
.tern-port
37+
#Hardhat files
38+
cache
39+
artifacts

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# time
2-
TIME Token
1+
# TIME
2+
3+
An ERC721 compliant Non-Fungible Token that allows you to own a piece of time.
+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.0;
4+
5+
//implementation of ERC721 Non-Fungible Token Standard
6+
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
7+
//implementation of ERC721 where tokens can be irreversibly burned (destroyed).
8+
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
9+
//implementation of ERC721 where transers can be paused
10+
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol";
11+
//For verifying messages in lazyMint
12+
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
13+
//Abstract that allows tokens to be listed and exchanged considering royalty fees
14+
import "./abstractions/ERC721Exchange.sol";
15+
16+
contract CollectableTime is ERC721, ERC721Burnable, ERC721Pausable, ERC721Exchange {
17+
//in only the contract owner can add a fee
18+
address private _admin;
19+
20+
modifier onlyAdmin {
21+
require(
22+
_msgSender() == _admin,
23+
"Time: Restricted method access to only the admin"
24+
);
25+
_;
26+
}
27+
28+
/**
29+
* @dev Constructor function
30+
*/
31+
constructor (string memory _name, string memory _symbol)
32+
ERC721(_name, _symbol)
33+
{
34+
_admin = _msgSender();
35+
}
36+
37+
/**
38+
* @dev Sets a fee that will be collected during the exchange method
39+
*/
40+
function allocate(address recipient, uint256 fee)
41+
external virtual onlyAdmin
42+
{
43+
_allocateFee(recipient, fee);
44+
}
45+
46+
/**
47+
* @dev Mints now and transfers to `recipient`
48+
*/
49+
function autoMint(address recipient)
50+
external virtual onlyAdmin
51+
{
52+
uint256 timestamp = block.timestamp;
53+
_safeMint(recipient, timestamp);
54+
}
55+
56+
/**
57+
* @dev Removes a fee
58+
*/
59+
function deallocate(address recipient)
60+
external virtual onlyAdmin
61+
{
62+
_deallocateFee(recipient);
63+
}
64+
65+
/**
66+
* @dev Allows anyone to self mint a token
67+
*/
68+
function lazyMint(uint256 tokenId, address recipient, bytes calldata proof)
69+
public virtual
70+
{
71+
//make sure the admin signed this off
72+
require(
73+
ECDSA.recover(
74+
ECDSA.toEthSignedMessageHash(
75+
keccak256(
76+
abi.encodePacked(tokenId, recipient)
77+
)
78+
),
79+
proof
80+
) == _admin,
81+
"Time: Invalid proof."
82+
);
83+
84+
_safeMint(recipient, tokenId);
85+
}
86+
87+
/**
88+
* @dev Mints `tokenId` and transfers to `recipient`
89+
*/
90+
function mint(uint256 tokenId, address recipient)
91+
external virtual onlyAdmin
92+
{
93+
_safeMint(recipient, tokenId);
94+
}
95+
96+
/**
97+
* @dev Lists `tokenId` on the order book for `amount` in wei.
98+
*/
99+
function list(uint256 tokenId, uint256 amount) external virtual {
100+
_list(tokenId, amount);
101+
}
102+
103+
/**
104+
* @dev Removes `tokenId` from the order book.
105+
*/
106+
function delist(uint256 tokenId) external virtual {
107+
_delist(tokenId);
108+
}
109+
110+
/**
111+
* @dev Allows for a sender to exchange `tokenId` for the listed amount
112+
*/
113+
function exchange(uint256 tokenId) external virtual override payable {
114+
_exchange(tokenId, msg.value);
115+
}
116+
117+
/**
118+
* @dev Pauses all token transfers.
119+
*
120+
* See {ERC721Pausable} and {Pausable-_pause}.
121+
*
122+
* Requirements:
123+
*
124+
* - the caller must have the `PAUSER_ROLE`.
125+
*/
126+
function pause() public virtual onlyAdmin {
127+
_pause();
128+
}
129+
130+
/**
131+
* @dev Returns the total supply of time
132+
*/
133+
function totalSupply() external view returns(uint256) {
134+
return block.timestamp;
135+
}
136+
137+
/**
138+
* @dev Unpauses all token transfers.
139+
*
140+
* See {ERC721Pausable} and {Pausable-_unpause}.
141+
*
142+
* Requirements:
143+
*
144+
* - the caller must have the `PAUSER_ROLE`.
145+
*/
146+
function unpause() public virtual onlyAdmin {
147+
_unpause();
148+
}
149+
150+
/**
151+
* @dev Resolves duplicate _beforeTokenTransfer method definition
152+
* between ERC721 and ERC721Pausable
153+
*/
154+
function _beforeTokenTransfer(
155+
address from,
156+
address to,
157+
uint256 tokenId
158+
) internal virtual override(ERC721, ERC721Pausable) {
159+
super._beforeTokenTransfer(from, to, tokenId);
160+
}
161+
}

0 commit comments

Comments
 (0)