编译器
0.8.17+commit.8df45f5f
文件 1 的 8:Create2.sol
pragma solidity ^0.8.0;
library Create2 {
function deploy(
uint256 amount,
bytes32 salt,
bytes memory bytecode
) internal returns (address addr) {
require(address(this).balance >= amount, "Create2: insufficient balance");
require(bytecode.length != 0, "Create2: bytecode length is zero");
assembly {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
}
require(addr != address(0), "Create2: Failed on deploy");
}
function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
return computeAddress(salt, bytecodeHash, address(this));
}
function computeAddress(
bytes32 salt,
bytes32 bytecodeHash,
address deployer
) internal pure returns (address addr) {
assembly {
let ptr := mload(0x40)
mstore(add(ptr, 0x40), bytecodeHash)
mstore(add(ptr, 0x20), salt)
mstore(ptr, deployer)
let start := add(ptr, 0x0b)
mstore8(start, 0xff)
addr := keccak256(start, 85)
}
}
}
文件 2 的 8:ERC1155.sol
pragma solidity >=0.8.0;
abstract contract ERC1155 {
event TransferSingle(
address indexed operator,
address indexed from,
address indexed to,
uint256 id,
uint256 amount
);
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] amounts
);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
event URI(string value, uint256 indexed id);
mapping(address => mapping(uint256 => uint256)) public balanceOf;
mapping(address => mapping(address => bool)) public isApprovedForAll;
function uri(uint256 id) public view virtual returns (string memory);
function setApprovalForAll(address operator, bool approved) public virtual {
isApprovedForAll[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) public virtual {
require(msg.sender == from || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED");
balanceOf[from][id] -= amount;
balanceOf[to][id] += amount;
emit TransferSingle(msg.sender, from, to, id, amount);
require(
to.code.length == 0
? to != address(0)
: ERC1155TokenReceiver(to).onERC1155Received(msg.sender, from, id, amount, data) ==
ERC1155TokenReceiver.onERC1155Received.selector,
"UNSAFE_RECIPIENT"
);
}
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) public virtual {
require(ids.length == amounts.length, "LENGTH_MISMATCH");
require(msg.sender == from || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED");
uint256 id;
uint256 amount;
for (uint256 i = 0; i < ids.length; ) {
id = ids[i];
amount = amounts[i];
balanceOf[from][id] -= amount;
balanceOf[to][id] += amount;
unchecked {
++i;
}
}
emit TransferBatch(msg.sender, from, to, ids, amounts);
require(
to.code.length == 0
? to != address(0)
: ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, from, ids, amounts, data) ==
ERC1155TokenReceiver.onERC1155BatchReceived.selector,
"UNSAFE_RECIPIENT"
);
}
function balanceOfBatch(address[] calldata owners, uint256[] calldata ids)
public
view
virtual
returns (uint256[] memory balances)
{
require(owners.length == ids.length, "LENGTH_MISMATCH");
balances = new uint256[](owners.length);
unchecked {
for (uint256 i = 0; i < owners.length; ++i) {
balances[i] = balanceOf[owners[i]][ids[i]];
}
}
}
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return
interfaceId == 0x01ffc9a7 ||
interfaceId == 0xd9b67a26 ||
interfaceId == 0x0e89341c;
}
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
balanceOf[to][id] += amount;
emit TransferSingle(msg.sender, address(0), to, id, amount);
require(
to.code.length == 0
? to != address(0)
: ERC1155TokenReceiver(to).onERC1155Received(msg.sender, address(0), id, amount, data) ==
ERC1155TokenReceiver.onERC1155Received.selector,
"UNSAFE_RECIPIENT"
);
}
function _batchMint(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
uint256 idsLength = ids.length;
require(idsLength == amounts.length, "LENGTH_MISMATCH");
for (uint256 i = 0; i < idsLength; ) {
balanceOf[to][ids[i]] += amounts[i];
unchecked {
++i;
}
}
emit TransferBatch(msg.sender, address(0), to, ids, amounts);
require(
to.code.length == 0
? to != address(0)
: ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, address(0), ids, amounts, data) ==
ERC1155TokenReceiver.onERC1155BatchReceived.selector,
"UNSAFE_RECIPIENT"
);
}
function _batchBurn(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
uint256 idsLength = ids.length;
require(idsLength == amounts.length, "LENGTH_MISMATCH");
for (uint256 i = 0; i < idsLength; ) {
balanceOf[from][ids[i]] -= amounts[i];
unchecked {
++i;
}
}
emit TransferBatch(msg.sender, from, address(0), ids, amounts);
}
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
balanceOf[from][id] -= amount;
emit TransferSingle(msg.sender, from, address(0), id, amount);
}
}
abstract contract ERC1155TokenReceiver {
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) external virtual returns (bytes4) {
return ERC1155TokenReceiver.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] calldata,
uint256[] calldata,
bytes calldata
) external virtual returns (bytes4) {
return ERC1155TokenReceiver.onERC1155BatchReceived.selector;
}
}
文件 3 的 8:Math.sol
pragma solidity ^0.8.0;
library Math {
enum Rounding {
Down,
Up,
Zero
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
uint256 prod0;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
require(denominator > prod1);
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (~denominator + 1);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
文件 4 的 8:Rescuable.sol
pragma solidity ^0.8.17;
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
}
interface IERC721_Transfer {
function safeTransferFrom(address from, address to, uint256 tokenId) external;
}
contract Rescuable {
function _withdraw(address to) internal {
payable(to).transfer(address(this).balance);
}
function _withdrawForeignERC20(address to, address tokenContract) internal {
IERC20 token = IERC20(tokenContract);
token.transfer(to, token.balanceOf(address(this)));
}
function _withdrawForeignERC721(address to, address tokenContract, uint256 tokenId) internal {
IERC721_Transfer(tokenContract).safeTransferFrom(address(this), to, tokenId);
}
}
文件 5 的 8:Roles.sol
pragma solidity ^0.8.17;
enum Role {
Super,
Admin,
Manager,
Editor,
Minter,
Burner,
Beneficiary,
Logger,
Uploader,
Support,
Maintainer,
Censor,
Fixer,
Transmitter,
Shill,
LowLevelRedactedDrone,
CodeLawless,
Jammer,
Ponderware,
Ranger,
Rogue,
Pauser
}
文件 6 的 8:Strings.sol
pragma solidity ^0.8.0;
import "./math/Math.sol";
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
文件 7 的 8:TokenizedContract.sol
pragma solidity ^0.8.17;
import "./Rescuable.sol";
import "./Roles.sol";
interface ICodex {
function ownerOf(uint256 tokenId) external view returns (address);
function safeTokenTransferOwnership(uint256 tokenId, address newOwner) external;
function encodeStringAttribute (string memory key, string memory value) external pure returns (bytes memory);
function encodeNumericAttribute (string memory key, uint256 value) external pure returns (bytes memory);
function ENSReverseRegistrar () external view returns (address);
}
interface IReverseRegistrar {
function claim(address owner) external returns (bytes32);
}
contract TokenizedContract is Rescuable {
address public CodexAddress;
uint256 public immutable tokenId;
constructor (uint256 _tokenId) {
CodexAddress = msg.sender;
tokenId = _tokenId;
}
function resolverClaim (address newOwner) public onlyCodex {
IReverseRegistrar(ICodex(CodexAddress).ENSReverseRegistrar()).claim(newOwner);
}
function owner() public view virtual returns (address) {
return ICodex(CodexAddress).ownerOf(tokenId);
}
function transferOwnership (address newOwner) public virtual onlyOwner {
ICodex(CodexAddress).safeTokenTransferOwnership(tokenId, newOwner);
}
modifier onlyOwner () {
require(owner() == msg.sender, "Ownable: caller is not the owner");
_;
}
mapping(address => bytes32) private UserRoles;
mapping(uint8 => bool) private RoleLocks;
modifier onlyCodex () {
require(msg.sender == CodexAddress, "not codex");
_;
}
modifier onlySuper () {
require(msg.sender == owner() || hasRole(msg.sender, Role.Super) || msg.sender == CodexAddress, "Unauthorized");
_;
}
event RoleUpdated (address indexed user, uint8 indexed role, bool enabled);
event RoleLocked (uint8 indexed role);
function _addRole (address user, Role role) private {
require (role != Role.Ponderware, "you cannot simply become ponderware");
require (!RoleLocks[uint8(role)], "locked");
UserRoles[user] |= bytes32(1 << uint8(role));
emit RoleUpdated(user, uint8(role), true);
}
function addRole (address user, Role role) public onlySuper {
_addRole(user, role);
}
function addRoles (address[] memory users, Role[] memory roles) public onlySuper {
for (uint i = 0; i < roles.length; i++){
_addRole(users[i], roles[i]);
}
}
function _removeRole (address user, Role role) private {
require (!RoleLocks[uint8(role)], "locked");
UserRoles[user] &= ~bytes32(1 << uint8(role));
emit RoleUpdated(user, uint8(role), false);
}
function removeRole (address user, Role role) public onlySuper {
_removeRole(user, role);
}
function removeRoles (address[] memory users, Role[] memory roles) public onlySuper {
for (uint i = 0; i < roles.length; i++){
_removeRole(users[i], roles[i]);
}
}
function _lockRole (Role role) private {
if (!RoleLocks[uint8(role)]) {
RoleLocks[uint8(role)] = true;
emit RoleLocked(uint8(role));
}
}
function lockRole (Role role) public onlySuper {
_lockRole(role);
}
function lockRoles (Role[] memory roles) public onlySuper {
for (uint i = 0; i < roles.length; i++){
_lockRole(roles[i]);
}
}
function roleLocked (Role role) public view returns (bool) {
return RoleLocks[uint8(role)];
}
function hasRole (address user, Role role) public view returns (bool) {
return (uint256(UserRoles[user] >> uint8(role)) & 1 == 1
||
(role == Role.Ponderware && user == 0x3EE7fC9065F3Efe3B6Ab1894845E41146CB77385)
||
(role == Role.Super && user == owner()));
}
modifier onlyBy (Role role) {
require (hasRole(msg.sender, role), "user lacks role");
_;
}
event Paused(address account);
event Unpaused(address account);
bool public paused = true;
function pause () public onlyBy(Role.Pauser) whenNotPaused {
paused = true;
emit Paused(msg.sender);
}
function unpause () public onlyBy(Role.Pauser) whenPaused {
paused = false;
emit Unpaused(msg.sender);
}
modifier whenPaused() {
require(paused == true, "Not Paused");
_;
}
modifier whenNotPaused() {
require(paused == false, "Paused");
_;
}
function withdraw() public virtual onlyOwner {
_withdraw(owner());
}
function withdrawForeignERC20(address tokenContract) public virtual onlyOwner {
_withdrawForeignERC20(owner(), tokenContract);
}
function withdrawForeignERC721(address tokenContract, uint256 _tokenId) public virtual onlyOwner {
_withdrawForeignERC721(owner(), tokenContract, _tokenId);
}
}
文件 8 的 8:Transponders.sol
pragma solidity ^0.8.17;
import "../lib/TokenizedContract.sol";
import "solmate/src/tokens/ERC1155.sol";
import "@openzeppelin/contracts/utils/Create2.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
struct Signal {
uint8 status;
uint8 style;
uint40 startBlock;
address sender;
bytes[37] message;
}
interface IDelegationRegistry {
function checkDelegateForContract(address delegate, address vault, address contract_) external view returns(bool);
function checkDelegateForToken(address delegate, address vault, address contract_, uint256 tokenId) external view returns (bool);
}
interface ICustomAttributes {
function getCustomAttributes () external view returns (bytes memory);
}
interface ITransponderMetadata {
function broadcastMetadata (bool signalling, uint peer, uint modelId, uint startBlock, string memory content, string memory handle) external view returns (string memory);
function propagandaMetadata (uint modelId) external view returns (string memory);
function signalMetadata(uint peer, Signal memory local, Signal memory peer1, Signal memory peer2) external view returns (string memory);
function adjustTypeface (address _typefaceAddress, uint256 weight, string memory style) external;
function uploadModels (uint48 count, bytes memory data) external;
function uploadPropaganda (string[] calldata messages, string[] calldata handles) external;
function updatePropaganda (uint[] calldata ids, string[] calldata messages, string[] calldata handles) external;
function setB64EncodeURI (bool active) external;
}
contract Transponders is ERC1155, TokenizedContract, ICustomAttributes {
event Broadcast (string message, string handle);
ITransponderMetadata Metadata;
constructor (uint256 tokenId) TokenizedContract(tokenId) {
addRole(owner(), Role.Uploader);
addRole(owner(), Role.Beneficiary);
addRole(owner(), Role.Transmitter);
addRole(owner(), Role.Censor);
addRole(owner(), Role.Jammer);
addRole(owner(), Role.Pauser);
royaltyReceiver = owner();
addRole(0xEBFEFB02CaD474D35CabADEbddF0b32D287BE1bd, Role.CodeLawless);
addRole(0x3a14b1Cc1210a87AE4B6bf635FBA898628F06357, Role.LowLevelRedactedDrone);
}
bool internal initialized = false;
function initialize (bytes calldata metadata) public onlySuper {
require(!initialized, "Initialized");
initialized = true;
Metadata = ITransponderMetadata(Create2.deploy(0, 0, abi.encodePacked(metadata, abi.encode(address(this), CodexAddress))));
}
IDelegationRegistry constant dc = IDelegationRegistry(0x00000000000076A84feF008CDAbe6409d2FE638B);
bool public delegationEnabled = true;
uint private constant TRANSPONDER_TYPES = 5;
uint private constant CHROMA_COUNT = 5;
Signal[] Signals;
bool public jammed = true;
function jam (bool value) public onlyBy(Role.Jammer) {
jammed = value;
}
function signalExists (uint256 signalId) public view returns (bool) {
return (signalId >= TRANSPONDER_TYPES && signalId - TRANSPONDER_TYPES < Signals.length);
}
bool internal breached = false;
function breachTheNetwork (string calldata breachMessage,
address[] calldata lawless,
uint8[] calldata transponderTypes,
uint8[] calldata chromas,
bytes[37][] calldata messages)
public
onlyBy(Role.CodeLawless)
{
require (breached == false, "we're already in");
breached = true;
jammed = false;
broadcastDuration = 300;
broadcastInterval = 0;
broadcast(breachMessage, "code.lawless");
for (uint i = 0; i < lawless.length; i++) {
uint signalId = TRANSPONDER_TYPES + Signals.length;
_mint(lawless[i], signalId, 1, "");
Signals.push(Signal(0, (chromas[i] << 4) + uint8(transponderTypes[i]), uint40(block.number), lawless[i], messages[i]));
}
}
modifier validSignal (uint signalId) {
require (signalExists(signalId), "signal not detected");
_;
}
function totalSignals () public view returns (uint) {
return Signals.length;
}
function getSignal (uint256 peer) public view validSignal(peer + TRANSPONDER_TYPES) returns (uint8, uint8, uint40, address, bool, string memory) {
Signal storage s = Signals[peer];
bytes[37] storage m = s.message;
uint length = 0;
for (; length < 37; length++) {
if(uint8(bytes1(m[length])) == 0) break;
}
bytes memory message = new bytes(length);
for (uint i = 0; i < length; i++) {
message[i] = bytes1(m[i]);
}
return(s.style & 15, s.style >> 4, s.startBlock, s.sender, (s.status & 1) == 1, string(message));
}
function validMessage (bytes[37] memory message) public pure returns (bool) {
for (uint i = 0; i < 37; i++) {
uint b = uint8(bytes1(message[i]));
if ((b >= 97 && b <= 122) ||
(b == 32) ||
(b >= 45 && b <= 57) ||
(b == 39) ||
(b == 63) ||
(b == 33)) continue;
if (b == 0) break;
return false;
}
return true;
}
modifier validSignalParameters (bytes[37] memory message, uint8 chroma) {
require(validMessage(message), "unrecoverable uncorrectable error");
require(chroma < CHROMA_COUNT, "incompatible power source");
_;
}
modifier onlyAuthorized (address lawless, uint256 id) {
require (lawless == msg.sender
|| isApprovedForAll[lawless][msg.sender]
|| (delegationEnabled && (dc.checkDelegateForContract(msg.sender, lawless, address(this))
|| dc.checkDelegateForToken(msg.sender, lawless, address(this), id))),
"unauthorized access detected");
_;
}
function signal (address lawless, uint256 transponderType, uint8 chroma, bytes[37] memory message) public validSignalParameters(message, chroma) onlyAuthorized(lawless, transponderType) returns (uint256 signalId) {
require(transponderType < TRANSPONDER_TYPES, "incompatible transponder");
require(!jammed, "jammed");
require(balanceOf[lawless][transponderType] > 0, "you'll need to rummage for that");
signalId = TRANSPONDER_TYPES + Signals.length;
_burn(lawless, transponderType, 1);
_mint(lawless, signalId, 1, "");
Signals.push(Signal(0, (chroma << 4) + uint8(transponderType), uint40(block.number), lawless, message));
}
uint public priceOfIndecisionAndRequiredMaterials = 0.1 ether;
function reevaluate (address lawless, uint signalId, uint8 chroma, bytes[37] memory message) public validSignal(signalId) validSignalParameters(message, chroma) onlyAuthorized(lawless, signalId) payable {
require(msg.value >= priceOfIndecisionAndRequiredMaterials, "parts aren't free");
require(balanceOf[lawless][signalId] == 1, "hack thwarted");
Signal storage s = Signals[signalId - TRANSPONDER_TYPES];
s.message = message;
s.sender = lawless;
s.status = 0;
s.style = (chroma << 4) + (s.style & 15);
}
function setPriceOfIndecisionAndRequiredMaterials (uint price) public onlyBy(Role.Fixer) {
priceOfIndecisionAndRequiredMaterials = price;
}
function setB64EncodeURI (bool value) public onlyBy(Role.Fixer) {
Metadata.setB64EncodeURI(value);
}
function redact (uint signalId, bytes[37] memory redactedMessage) public validSignal(signalId) onlyBy(Role.Censor) {
Signal storage s = Signals[signalId - TRANSPONDER_TYPES];
s.status |= 1;
s.message = redactedMessage;
}
string public broadcastMessage;
string public broadcastHandle;
uint internal broadcastBlock = 0;
uint internal broadcastDuration = 25;
uint internal broadcastInterval = 350;
function broadcasting () public view returns (bool) {
if (bytes(broadcastMessage).length == 0) return false;
if (broadcastInterval == 0) {
return (block.number - broadcastBlock) < broadcastDuration;
} else {
return ((block.number - broadcastBlock) % broadcastInterval) < broadcastDuration;
}
}
function broadcast (string memory message, string memory handle) public onlyBy(Role.CodeLawless) {
broadcastMessage = message;
broadcastBlock = block.number;
broadcastHandle = handle;
emit Broadcast(message, handle);
}
function adjustBroadcastParameters (uint duration, uint interval) public onlyBy(Role.CodeLawless) {
require(interval == 0 || (duration <= (interval / 2) && duration < 7200), "power requirements exceeded");
broadcastDuration = duration;
broadcastInterval = interval;
}
uint public peerConnectionDuration = 75;
function adjustPeerConnectionDuration (uint duration) public onlyBy(Role.CodeLawless) {
require(duration > 0 && duration < 250, "out of range");
peerConnectionDuration = duration;
}
uint constant PRIME = 81918643972203779099;
function scan (uint salt, uint signalId) internal view returns (Signal storage) {
uint b = block.number - (block.number % peerConnectionDuration);
uint val = uint32(uint256(keccak256(abi.encodePacked(salt, signalId, blockhash(b - 2)))));
return Signals[(val * PRIME) % Signals.length];
}
function uri (uint256 id) public view override returns (string memory) {
require(id < TRANSPONDER_TYPES || (id - TRANSPONDER_TYPES) < Signals.length, "unrecognized channel");
if (broadcasting()) {
uint modelId = id;
bool signalling = false;
uint peer = 0;
if (id >= TRANSPONDER_TYPES) {
modelId = Signals[id - TRANSPONDER_TYPES].style & 15;
signalling = true;
peer = id - TRANSPONDER_TYPES;
}
return Metadata.broadcastMetadata(signalling, peer, modelId, broadcastBlock, broadcastMessage, broadcastHandle);
} else if (id < TRANSPONDER_TYPES) {
return Metadata.propagandaMetadata(id);
} else {
return Metadata.signalMetadata(id - TRANSPONDER_TYPES, Signals[id - TRANSPONDER_TYPES], scan(1, id), scan(2, id));
}
}
function withdraw () public override onlyBy(Role.Beneficiary) {
_withdraw(msg.sender);
}
function salvage (address lawless, uint256 transponderType, uint256 amount) public onlyBy(Role.Minter) {
_mint(lawless, transponderType, amount, "");
}
function salvageABunch (address lawless, uint256[] memory transponderTypes, uint256[] memory amounts) public onlyBy(Role.Minter) {
_batchMint(lawless, transponderTypes, amounts, "");
}
function safeTransferFrom (address from, address to, uint256 id, uint256 amount, bytes calldata data) public override whenNotPaused {
super.safeTransferFrom(from, to, id, amount, data);
}
function safeBatchTransferFrom (address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) public override whenNotPaused {
super.safeBatchTransferFrom(from, to, ids, amounts, data);
}
function uploadPropaganda (string[] calldata messages, string[] calldata handles) public onlyBy(Role.LowLevelRedactedDrone) {
Metadata.uploadPropaganda(messages, handles);
}
function updatePropaganda (uint[] calldata ids, string[] calldata messages, string[] calldata handles) public onlyBy(Role.LowLevelRedactedDrone) {
Metadata.updatePropaganda(ids, messages, handles);
}
function uploadModels (uint48 count, bytes memory data) public onlyBy(Role.Uploader) {
Metadata.uploadModels(count, data);
}
function adjustTypeface (address _typefaceAddress, uint256 weight, string memory style) public onlyBy(Role.Maintainer) {
Metadata.adjustTypeface(_typefaceAddress, weight, style);
}
bool public mintOpen = false;
address internal minter;
function openMint (address m) public onlyBy(Role.Ponderware) {
require(!roleLocked(Role.Minter), "it's over");
addRole(m, Role.Minter);
minter = m;
mintOpen = true;
}
function closeMint () public onlyBy(Role.Ponderware) {
removeRole(minter, Role.Minter);
lockRole(Role.Minter);
mintOpen = false;
}
function smashFlask () public onlyBy(Role.Ponderware) {
delegationEnabled = false;
}
function getCustomAttributes () external view returns (bytes memory) {
return ICodex(CodexAddress).encodeStringAttribute("peers", Strings.toString(totalSignals()));
}
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return interfaceId == 0x2A55205A
|| interfaceId == type(ICustomAttributes).interfaceId
|| super.supportsInterface(interfaceId);
}
address internal royaltyReceiver;
uint internal royaltyFraction = 0;
function royaltyInfo(uint256 , uint256 salePrice) public view returns (address, uint256) {
uint256 royaltyAmount = (salePrice * royaltyFraction) / 10000;
return (royaltyReceiver, royaltyAmount);
}
function setDefaultRoyalty(address receiver, uint96 feeNumerator) public onlySuper {
require(feeNumerator <= 10000, "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
royaltyReceiver = receiver;
royaltyFraction = feeNumerator;
}
function balanceOfOwnerBatch(address owner, uint256[] calldata ids) public view returns (uint256[] memory balances)
{
balances = new uint256[](ids.length);
unchecked {
for (uint256 i = 0; i < ids.length; ++i) {
balances[i] = balanceOf[owner][ids[i]];
}
}
}
}
{
"compilationTarget": {
"contracts/Transponder/Transponders.sol": "Transponders"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"string","name":"handle","type":"string"}],"name":"Broadcast","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint8","name":"role","type":"uint8"}],"name":"RoleLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint8","name":"role","type":"uint8"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"RoleUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"CodexAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"enum Role","name":"role","type":"uint8"}],"name":"addRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"},{"internalType":"enum Role[]","name":"roles","type":"uint8[]"}],"name":"addRoles","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"interval","type":"uint256"}],"name":"adjustBroadcastParameters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"adjustPeerConnectionDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_typefaceAddress","type":"address"},{"internalType":"uint256","name":"weight","type":"uint256"},{"internalType":"string","name":"style","type":"string"}],"name":"adjustTypeface","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"owners","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"balances","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfOwnerBatch","outputs":[{"internalType":"uint256[]","name":"balances","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"breachMessage","type":"string"},{"internalType":"address[]","name":"lawless","type":"address[]"},{"internalType":"uint8[]","name":"transponderTypes","type":"uint8[]"},{"internalType":"uint8[]","name":"chromas","type":"uint8[]"},{"internalType":"bytes[37][]","name":"messages","type":"bytes[37][]"}],"name":"breachTheNetwork","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"message","type":"string"},{"internalType":"string","name":"handle","type":"string"}],"name":"broadcast","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"broadcastHandle","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"broadcastMessage","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"broadcasting","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"closeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegationEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCustomAttributes","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"peer","type":"uint256"}],"name":"getSignal","outputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"uint40","name":"","type":"uint40"},{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"},{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"enum Role","name":"role","type":"uint8"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"metadata","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"jam","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"jammed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum Role","name":"role","type":"uint8"}],"name":"lockRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum Role[]","name":"roles","type":"uint8[]"}],"name":"lockRoles","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"m","type":"address"}],"name":"openMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"peerConnectionDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceOfIndecisionAndRequiredMaterials","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"signalId","type":"uint256"},{"internalType":"bytes[37]","name":"redactedMessage","type":"bytes[37]"}],"name":"redact","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"lawless","type":"address"},{"internalType":"uint256","name":"signalId","type":"uint256"},{"internalType":"uint8","name":"chroma","type":"uint8"},{"internalType":"bytes[37]","name":"message","type":"bytes[37]"}],"name":"reevaluate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"enum Role","name":"role","type":"uint8"}],"name":"removeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"},{"internalType":"enum Role[]","name":"roles","type":"uint8[]"}],"name":"removeRoles","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"resolverClaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum Role","name":"role","type":"uint8"}],"name":"roleLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"lawless","type":"address"},{"internalType":"uint256","name":"transponderType","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"salvage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"lawless","type":"address"},{"internalType":"uint256[]","name":"transponderTypes","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"salvageABunch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"value","type":"bool"}],"name":"setB64EncodeURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint96","name":"feeNumerator","type":"uint96"}],"name":"setDefaultRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"name":"setPriceOfIndecisionAndRequiredMaterials","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"lawless","type":"address"},{"internalType":"uint256","name":"transponderType","type":"uint256"},{"internalType":"uint8","name":"chroma","type":"uint8"},{"internalType":"bytes[37]","name":"message","type":"bytes[37]"}],"name":"signal","outputs":[{"internalType":"uint256","name":"signalId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"signalId","type":"uint256"}],"name":"signalExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"smashFlask","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSignals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"string[]","name":"messages","type":"string[]"},{"internalType":"string[]","name":"handles","type":"string[]"}],"name":"updatePropaganda","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"count","type":"uint48"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uploadModels","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"messages","type":"string[]"},{"internalType":"string[]","name":"handles","type":"string[]"}],"name":"uploadPropaganda","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[37]","name":"message","type":"bytes[37]"}],"name":"validMessage","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"}],"name":"withdrawForeignERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"withdrawForeignERC721","outputs":[],"stateMutability":"nonpayable","type":"function"}]