Verified contractExactMIT
Registry
Address0x1d4b69508a5084cdc54e248896fcd72e0d040b0a
- Balance
0 ETH
- Transactions
2
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,249,074
- Creation transaction
- 0xb85c8c9c8c…8f37be2a7c
4 files
src/Registry.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Record} from "./lib/Task.sol";
contract Registry is Ownable {
string public constant BootMode = "1";
uint256 public constant MAX_CODE = 24576;
address public kernel;
uint256 public count;
mapping(uint256 => bytes) private _code;
mapping(uint256 => Record) private _records;
event KernelBound(address kernel);
event Installed(uint256 indexed policy, uint256 indexed author, bytes32 codeHash, uint256 size, uint256 fee);
error NotKernel();
error AlreadyBound();
error ZeroAddress();
error EmptyCode();
error CodeTooLarge(uint256 size);
constructor(address owner_) Ownable(owner_) {}
modifier onlyKernel() {
if (msg.sender != kernel) revert NotKernel();
_;
}
function bind(address kernel_) external onlyOwner {
if (kernel != address(0)) revert AlreadyBound();
if (kernel_ == address(0)) revert ZeroAddress();
kernel = kernel_;
emit KernelBound(kernel_);
}
function install(bytes memory code, uint256 author, uint256 fee) external onlyKernel returns (uint256 policy) {
if (code.length == 0) revert EmptyCode();
if (code.length > MAX_CODE) revert CodeTooLarge(code.length);
policy = ++count;
bytes32 codeHash = keccak256(code);
_code[policy] = code;
_records[policy] = Record({
id: policy,
author: author,
installedAt: uint64(block.timestamp),
size: uint32(code.length),
tasks: 0,
codeHash: codeHash,
feesPaid: 0
});
emit Installed(policy, author, codeHash, code.length, fee);
}
function tally(uint256 policy, uint256 fee) external onlyKernel {
Record storage r = _records[policy];
r.tasks += 1;
r.feesPaid += fee;
}
function codeOf(uint256 policy) external view returns (bytes memory) {
return _code[policy];
}
function record(uint256 policy) external view returns (Record memory) {
return _records[policy];
}
function records(uint256 from, uint256 to) external view returns (Record[] memory list) {
if (from == 0) from = 1;
if (to > count) to = count;
if (from > to) return list;
list = new Record[](to - from + 1);
for (uint256 i = from; i <= to; i++) {
list[i - from] = _records[i];
}
}
}
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
src/lib/Task.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
struct Task {
address wallet;
bool swapped;
uint256 policy;
bytes input;
uint256 feeLimit;
uint256 ethIn;
uint256 fill;
}
struct Log {
uint256 policy;
bytes32[] topics;
bytes data;
}
struct Record {
uint256 id;
uint256 author;
uint64 installedAt;
uint32 size;
uint64 tasks;
bytes32 codeHash;
uint256 feesPaid;
}
library Identity {
uint256 internal constant POLICY_BIT = 1 << 255;
function wallet(address a) internal pure returns (uint256) {
return uint256(uint160(a));
}
function policy(uint256 id) internal pure returns (uint256) {
return POLICY_BIT | id;
}
function bare(uint256 identity) internal pure returns (uint256) {
return identity & ~POLICY_BIT;
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.