Blockchain / Global / Address
Contract
0x232eA20eDb71867504aCa3d6D3E18d65EA562e90
- Balance
- 0 SOMI
- Transactions sent
- 1
- Type
- Contract · 6,219 bytes of code
SantaScores Verified
- Compiler
- solc 0.8.28+commit.7893614a
- Language
- Solidity
- Optimization
- No
- EVM version
- prague
- License
- —
- Verified
- 2026-10-12
src/SantaScores.sol
Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract SantaScores {
struct Score {
address player;
string username;
uint256 score;
uint256 bestStreak;
uint256 timestamp;
}
mapping(address => Score[]) public playerScores;
mapping(address => Score) public playerBestScore;
Score[] public allScores;
address public owner;
event ScoreSubmitted(
address indexed player,
string username,
uint256 score,
uint256 bestStreak,
uint256 timestamp
);
event NewHighScore(
address indexed player,
string username,
uint256 score,
uint256 timestamp
);
constructor() {
owner = msg.sender;
}
function submitScore(
string memory _username,
uint256 _score,
uint256 _bestStreak
) public {
require(_score > 0, "Score must be greater than 0");
require(bytes(_username).length > 0, "Username required");
Score memory newScore = Score({
player: msg.sender,
username: _username,
score: _score,
bestStreak: _bestStreak,
timestamp: block.timestamp
});
playerScores[msg.sender].push(newScore);
allScores.push(newScore);
if (playerBestScore[msg.sender].score < _score) {
playerBestScore[msg.sender] = newScore;
emit NewHighScore(msg.sender, _username, _score, block.timestamp);
}
emit ScoreSubmitted(msg.sender, _username, _score, _bestStreak, block.timestamp);
}
function getPlayerScores(address _player) public view returns (Score[] memory) {
return playerScores[_player];
}
function getPlayerBestScore(address _player) public view returns (Score memory) {
return playerBestScore[_player];
}
function getHighScore(address _player)
external
view
returns(uint256 score, uint256 bestStreak, string memory username)
{
Score memory best = playerBestScore[_player];
return (
best.score,
best.bestStreak,
best.username
);
}
function getAllScoresCount() public view returns (uint256) {
return allScores.length;
}
}
ABI · 12 entries
json
[
{
"type": "constructor",
"inputs": [],
"stateMutability": "nonpayable"
},
{
"name": "NewHighScore",
"type": "event",
"inputs": [
{
"name": "player",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "username",
"type": "string",
"indexed": false,
"internalType": "string"
},
{
"name": "score",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"name": "ScoreSubmitted",
"type": "event",
"inputs": [
{
"name": "player",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "username",
"type": "string",
"indexed": false,
"internalType": "string"
},
{
"name": "score",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "bestStreak",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"name": "allScores",
"type": "function",
"inputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "player",
"type": "address",
"internalType": "address"
},
{
"name": "username",
"type": "string",
"internalType": "string"
},
{
"name": "score",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "bestStreak",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "getAllScoresCount",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "getHighScore",
"type": "function",
"inputs": [
{
"name": "_player",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "score",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "bestStreak",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "username",
"type": "string",
"internalType": "string"
}
],
"stateMutability": "view"
},
{
"name": "getPlayerBestScore",
"type": "function",
"inputs": [
{
"name": "_player",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "tuple",
"components": [
{
"name": "player",
"type": "address",
"internalType": "address"
},
{
"name": "username",
"type": "string",
"internalType": "string"
},
{
"name": "score",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "bestStreak",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct SantaScores.Score"
}
],
"stateMutability": "view"
},
{
"name": "getPlayerScores",
"type": "function",
"inputs": [
{
"name": "_player",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "",
"type": "tuple[]",
"components": [
{
"name": "player",
"type": "address",
"internalType": "address"
},
{
"name": "username",
"type": "string",
"internalType": "string"
},
{
"name": "score",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "bestStreak",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct SantaScores.Score[]"
}
],
"stateMutability": "view"
},
{
"name": "owner",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "playerBestScore",
"type": "function",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"outputs": [
{
"name": "player",
"type": "address",
"internalType": "address"
},
{
"name": "username",
"type": "string",
"internalType": "string"
},
{
"name": "score",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "bestStreak",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "playerScores",
"type": "function",
"inputs": [
{
"name": "",
"type": "address",
"internalType": "address"
},
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "player",
"type": "address",
"internalType": "address"
},
{
"name": "username",
"type": "string",
"internalType": "string"
},
{
"name": "score",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "bestStreak",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "timestamp",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"name": "submitScore",
"type": "function",
"inputs": [
{
"name": "_username",
"type": "string",
"internalType": "string"
},
{
"name": "_score",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "_bestStreak",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
}
]