-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWalletScore.sol
68 lines (58 loc) · 2.12 KB
/
WalletScore.sol
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/[email protected]/token/ERC721/ERC721.sol";
import "@openzeppelin/[email protected]/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/[email protected]/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";
contract WalletScore is ERC721, ERC721URIStorage, ERC721Burnable, Ownable {
uint256 private _nextTokenId;
// Max score for that address
mapping(address => uint) private _score;
mapping(address => uint) public mints_left;
constructor(
address initialOwner
) ERC721("WalletScore", "WLS") Ownable(initialOwner) {}
function score(address addr) external view returns (uint) {
return _score[addr];
}
function prepare_mint() external payable {
require(msg.value == 100000000000, "need to pay 0.0000001 matic");
mints_left[msg.sender] += 1;
}
function safeMint(
address to,
uint wallet_score,
string memory tokenUri
) public onlyOwner {
require(mints_left[to] > 0, "no mints left");
mints_left[to] -= 1;
uint256 tokenId = _nextTokenId++;
_score[to] = wallet_score;
_safeMint(to, tokenId);
_setTokenURI(tokenId, tokenUri);
}
function tokenURI(
uint256 tokenId
) public view override(ERC721, ERC721URIStorage) returns (string memory) {
return super.tokenURI(tokenId);
}
function supportsInterface(
bytes4 interfaceId
) public view override(ERC721, ERC721URIStorage) returns (bool) {
return super.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(
address from,
address to,
uint256
) internal pure {
require(
from == address(0) || to == address(0),
"This a Soulbound token. It cannot be transferred. It can only be burned by the token owner."
);
}
function payout(uint256 amt) public onlyOwner {
(bool sent, ) = address(msg.sender).call{value: amt}("");
require(sent, "Transaction failer");
}
}