Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Duelling
- Optimization enabled
- false
- Compiler version
- v0.8.28+commit.7893614a
- EVM Version
- Verified at
- 2026-09-18T22:50:18.525712Z
Constructor Arguments
Duelling.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// @title Duelling — whether you are up for a fight, and nothing else.
/// @notice One bit per address. Not a token, no ids, no standard, no supply: the same shape
/// Inventory is, one bit wide. A thing being state rather than a token is not a
/// reason to keep it off a chain — it is most of the argument for putting it on one.
///
/// What this buys over a server-side setting is that it follows you. Say once that
/// you would rather be left alone and every town that reads this contract knows it,
/// including ones nobody has written yet. A setting held by a server is a setting you
/// make again on the next server, and the one time you forget is the time it matters.
///
/// @dev Default is IN. `optedOut` rather than `fighting`, so an address that has never
/// touched this contract reads false and is therefore in — a town where you have to
/// opt in to being hit is a town where nobody is ever hit, and a fresh wallet should
/// not have to transact to join in.
///
/// The chain does not enforce anything here and cannot: whether a blow lands is
/// decided by two players' positions at one instant, which only the thing holding
/// both can judge. This is a statement of intent that servers honour, which is the
/// honest description of it. A server that ignored it would be a server nobody plays
/// on, and that is the only enforcement a preference can have.
///
/// Ownerless: no admin, no pause, no upgrade, no privileged address. Nobody can set
/// this for you and nobody can clear it.
contract Duelling {
/// @notice True when `who` has asked to be left out of it.
mapping(address => bool) public optedOut;
event Changed(address indexed who, bool fighting);
/// @notice Say whether you are up for a fight. Yours to set and nobody else's.
///
/// @dev The parameter is `on` rather than `fighting` because a parameter of that name
/// shadows the view below it, which the compiler warns about and which would make
/// one of them mean the other inside this function.
function setFighting(bool on) external {
optedOut[msg.sender] = !on;
emit Changed(msg.sender, on);
}
/// @notice Whether `who` is up for a fight. True for anyone who has never said otherwise.
function fighting(address who) external view returns (bool) {
return !optedOut[who];
}
/// @notice The same question for a crowd, so a server joining thirty players reads once
/// instead of thirty times.
function fightingMany(address[] calldata who) external view returns (bool[] memory out) {
out = new bool[](who.length);
for (uint256 i = 0; i < who.length; i++) out[i] = !optedOut[who[i]];
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","metadata"]}},"optimizer":{"runs":200,"enabled":true},"evmVersion":"shanghai"}
Contract ABI
[{"type":"event","name":"Changed","inputs":[{"type":"address","name":"who","internalType":"address","indexed":true},{"type":"bool","name":"fighting","internalType":"bool","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"fighting","inputs":[{"type":"address","name":"who","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool[]","name":"out","internalType":"bool[]"}],"name":"fightingMany","inputs":[{"type":"address[]","name":"who","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"optedOut","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFighting","inputs":[{"type":"bool","name":"on","internalType":"bool"}]}]
Contract Creation Code
0x6080604052348015600e575f5ffd5b5061036a8061001c5f395ff3fe608060405234801561000f575f5ffd5b506004361061004a575f3560e01c80636cae7d0f1461004e578063944644c114610085578063bd37ac18146100b1578063d4e76132146100d1575b5f5ffd5b61007061005c36600461020b565b5f6020819052908152604090205460ff1681565b60405190151581526020015b60405180910390f35b61007061009336600461020b565b6001600160a01b03165f9081526020819052604090205460ff161590565b6100c46100bf366004610238565b6100e6565b60405161007c91906102a9565b6100e46100df3660046102ed565b6101b3565b005b60608167ffffffffffffffff8111156101015761010161030c565b60405190808252806020026020018201604052801561012a578160200160208202803683370190505b5090505f5b828110156101ac575f5f85858481811061014b5761014b610320565b9050602002016020810190610160919061020b565b6001600160a01b0316815260208101919091526040015f2054825160ff909116159083908390811061019457610194610320565b9115156020928302919091019091015260010161012f565b5092915050565b335f8181526020819052604090819020805460ff19168415179055517faff804d10ec350c983486e846f0fa82d185d598dc17cf44c56a05cd42605a2309061020090841515815260200190565b60405180910390a250565b5f6020828403121561021b575f5ffd5b81356001600160a01b0381168114610231575f5ffd5b9392505050565b5f5f60208385031215610249575f5ffd5b823567ffffffffffffffff81111561025f575f5ffd5b8301601f8101851361026f575f5ffd5b803567ffffffffffffffff811115610285575f5ffd5b8560208260051b8401011115610299575f5ffd5b6020919091019590945092505050565b602080825282518282018190525f918401906040840190835b818110156102e257835115158352602093840193909201916001016102c2565b509095945050505050565b5f602082840312156102fd575f5ffd5b81358015158114610231575f5ffd5b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffdfea26469706673582212202baf09484932545208e8ae3313438e05e20e8aecc7be80f3a69854531423e10d64736f6c634300081c0033
Deployed ByteCode
0x608060405234801561000f575f5ffd5b506004361061004a575f3560e01c80636cae7d0f1461004e578063944644c114610085578063bd37ac18146100b1578063d4e76132146100d1575b5f5ffd5b61007061005c36600461020b565b5f6020819052908152604090205460ff1681565b60405190151581526020015b60405180910390f35b61007061009336600461020b565b6001600160a01b03165f9081526020819052604090205460ff161590565b6100c46100bf366004610238565b6100e6565b60405161007c91906102a9565b6100e46100df3660046102ed565b6101b3565b005b60608167ffffffffffffffff8111156101015761010161030c565b60405190808252806020026020018201604052801561012a578160200160208202803683370190505b5090505f5b828110156101ac575f5f85858481811061014b5761014b610320565b9050602002016020810190610160919061020b565b6001600160a01b0316815260208101919091526040015f2054825160ff909116159083908390811061019457610194610320565b9115156020928302919091019091015260010161012f565b5092915050565b335f8181526020819052604090819020805460ff19168415179055517faff804d10ec350c983486e846f0fa82d185d598dc17cf44c56a05cd42605a2309061020090841515815260200190565b60405180910390a250565b5f6020828403121561021b575f5ffd5b81356001600160a01b0381168114610231575f5ffd5b9392505050565b5f5f60208385031215610249575f5ffd5b823567ffffffffffffffff81111561025f575f5ffd5b8301601f8101851361026f575f5ffd5b803567ffffffffffffffff811115610285575f5ffd5b8560208260051b8401011115610299575f5ffd5b6020919091019590945092505050565b602080825282518282018190525f918401906040840190835b818110156102e257835115158352602093840193909201916001016102c2565b509095945050505050565b5f602082840312156102fd575f5ffd5b81358015158114610231575f5ffd5b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffdfea26469706673582212202baf09484932545208e8ae3313438e05e20e8aecc7be80f3a69854531423e10d64736f6c634300081c0033