Verified contractExactMIT
IMDBotIdentityStamp
Address0xab70b8f8a376deece0a195e8c5f9d97b54ae192d
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.34
- Same code
1 more contract
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,949,586
- Creation transaction
- 0x1e5db1e5eb…849f5f482d
- Main copy (most transactions)
- 0xad7c6aec…774b124b
imdbot/IdentityStamp.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
// ___
// / \
// )) | o | (( imd.bot
// \___/ automated dev thesis, on fomo
// for identity.md
// {{ imd.bot :: IdentityStamp.sol }}
//
// A claim references its identity.md by hash, not by trust. Uphold
// it or dispute it; cross the threshold either way and the
// verified flag moves. Amend the hash and it has to earn that flag
// back from zero.
contract IMDBotIdentityStamp {
struct Claim {
address claimant;
string name;
bytes32 docHash;
uint64 submittedAt;
uint32 upholds;
uint32 disputes;
bool verified;
}
uint32 public constant VERIFY_THRESHOLD = 5;
mapping(uint256 => Claim) public claims;
uint256 public claimCount;
mapping(uint256 => mapping(address => int8)) public voteOf;
event NoOp(string reason);
event ClaimSubmitted(uint256 indexed id, address indexed claimant, bytes32 docHash);
event Upheld(uint256 indexed id, address indexed voter, uint32 newUpholds);
event Disputed(uint256 indexed id, address indexed voter, uint32 newDisputes);
event VoteWithdrawn(uint256 indexed id, address indexed voter);
event DocHashAmended(uint256 indexed id, bytes32 newHash);
event VerificationFlipped(uint256 indexed id, bool verified);
function submitClaim(string calldata name, bytes32 docHash) external returns (uint256 id) {
id = ++claimCount;
claims[id] = Claim({
claimant: msg.sender,
name: name,
docHash: docHash,
submittedAt: uint64(block.timestamp),
upholds: 0,
disputes: 0,
verified: false
});
emit ClaimSubmitted(id, msg.sender, docHash);
}
function upholdClaim(uint256 id) external {
Claim storage c = claims[id];
if (c.claimant == address(0) || voteOf[id][msg.sender] == 1) {
emit NoOp("cannot uphold");
return;
}
if (voteOf[id][msg.sender] == -1) c.disputes -= 1;
voteOf[id][msg.sender] = 1;
c.upholds += 1;
emit Upheld(id, msg.sender, c.upholds);
_recheck(id);
}
function disputeClaim(uint256 id) external {
Claim storage c = claims[id];
if (c.claimant == address(0) || voteOf[id][msg.sender] == -1) {
emit NoOp("cannot dispute");
return;
}
if (voteOf[id][msg.sender] == 1) c.upholds -= 1;
voteOf[id][msg.sender] = -1;
c.disputes += 1;
emit Disputed(id, msg.sender, c.disputes);
_recheck(id);
}
function withdrawVote(uint256 id) external {
Claim storage c = claims[id];
int8 v = voteOf[id][msg.sender];
if (v == 0) {
emit NoOp("no vote to withdraw");
return;
}
if (v == 1) c.upholds -= 1;
else c.disputes -= 1;
voteOf[id][msg.sender] = 0;
emit VoteWithdrawn(id, msg.sender);
_recheck(id);
}
function amendDocHash(uint256 id, bytes32 newHash) external {
Claim storage c = claims[id];
if (c.claimant != msg.sender) {
emit NoOp("not the claimant");
return;
}
c.docHash = newHash;
c.upholds = 0;
c.disputes = 0;
if (c.verified) {
c.verified = false;
emit VerificationFlipped(id, false);
}
emit DocHashAmended(id, newHash);
}
function _recheck(uint256 id) internal {
Claim storage c = claims[id];
bool shouldVerify = c.upholds >= VERIFY_THRESHOLD && c.upholds > c.disputes;
if (shouldVerify != c.verified) {
c.verified = shouldVerify;
emit VerificationFlipped(id, shouldVerify);
}
}
function getClaim(uint256 id) external view returns (Claim memory) {
return claims[id];
}
function isVerified(uint256 id) external view returns (bool) {
return claims[id].verified;
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.