Verified contractPartialMIT
inceChainrealm
Address0xeb3fef93db3c9dad6858bce088f8f390fbb868c8
- Balance
0 ETH
- Transactions
5
- Compiler
solc 0.8.30
- Same code
92 more contracts
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 10,000 runs
- EVM version
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,294,384
- Creation transaction
- 0x2d05de25af…8c4bbb7e4e
- Main copy (most transactions)
- 0x61ed8d89…f32f068c
4 files
- inceChainrealm.solmain8.09 KB
- EInceChainverse.sol672 B
- IInceChainverse.sol2.73 KB
- inceChainverse.sol5.85 KB
inceChainrealm.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import "./IInceChainverse.sol";
import "./EInceChainverse.sol";
/**
* @title inceChainrealm - Per-Node Compute Realm
* @author inceptum.cloud
* @notice Deterministic per-node realm: bound to node identity, Flex
* settlement, USDC task-fee channel and CXT withdrawal.
* Only owner can trigger signer-authorized Flex minting
*/
contract inceChainrealm {
address public immutable chainverse;
address public immutable owner;
address public immutable corexMiner;
address public immutable corexToken;
address public immutable chainhole;
string public name;
string public metadata;
uint256 private _locked;
uint256 public totalEarned;
uint256 public totalWithdrawn;
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
event RealmInitialized(address indexed owner, string name);
event SignatureVerificationFailed(
address indexed owner,
address indexed to,
uint256 timestamp
);
event WithdrawnToWallet(
address indexed owner,
uint256 amount,
uint256 timestamp
);
event WithdrawnToRealm(
address indexed owner,
uint256 amount,
uint256 timestamp
);
event WithdrawnFromBalance(
address indexed owner,
uint256 amount,
uint256 timestamp
);
event Transferred(
address indexed from,
address indexed to,
uint256 amount,
uint256 timestamp
);
event Burned(address indexed token, uint256 amount, uint256 timestamp);
modifier onlyOwner() {
if (msg.sender != owner) revert Unauthorized();
_;
}
modifier onlyChainverse() {
if (msg.sender != chainverse) revert Unauthorized();
_;
}
modifier nonReentrant() {
if (_locked == _ENTERED) revert Unauthorized();
_locked = _ENTERED;
_;
_locked = _NOT_ENTERED;
}
constructor(
address _owner,
address _corexMiner,
address _corexToken,
address _chainhole,
string memory _name,
string memory _metadata
) {
if (_owner == address(0)) revert ZeroAddress();
if (_corexMiner == address(0)) revert ZeroAddress();
if (_corexToken == address(0)) revert ZeroAddress();
if (_chainhole == address(0)) revert ZeroAddress();
chainverse = msg.sender;
owner = _owner;
corexMiner = _corexMiner;
corexToken = _corexToken;
chainhole = _chainhole;
name = _name;
metadata = _metadata;
_locked = _NOT_ENTERED;
emit RealmInitialized(_owner, _name);
}
function withdrawToWallet(
uint256 amount,
uint256 deadline,
bytes32 signatureNonce,
uint8 v,
bytes32 r,
bytes32 s
) external onlyOwner nonReentrant returns (bool) {
if (amount == 0) revert ZeroAmount();
bool isSignatureValid = IcorexMiner(corexMiner).verifyFlexMintSignature(
address(this),
owner,
amount,
deadline,
signatureNonce,
v,
r,
s
);
if (!isSignatureValid) {
emit SignatureVerificationFailed(owner, owner, block.timestamp);
revert InvalidSignature();
}
if (!isSignatureValid) revert InvalidSignature();
bool success = IcorexMiner(corexMiner).mintFlex(
owner,
amount,
deadline,
signatureNonce,
v,
r,
s
);
if (!success) revert MintFlexFailed();
unchecked {
totalEarned += amount;
totalWithdrawn += amount;
}
emit WithdrawnToWallet(owner, amount, block.timestamp);
return true;
}
function withdrawToRealm(
uint256 amount,
uint256 deadline,
bytes32 signatureNonce,
uint8 v,
bytes32 r,
bytes32 s
) external onlyOwner nonReentrant returns (bool) {
if (amount == 0) revert ZeroAmount();
bool isSignatureValid = IcorexMiner(corexMiner).verifyFlexMintSignature(
address(this),
address(this),
amount,
deadline,
signatureNonce,
v,
r,
s
);
if (!isSignatureValid) {
emit SignatureVerificationFailed(
owner,
address(this),
block.timestamp
);
revert InvalidSignature();
}
bool success = IcorexMiner(corexMiner).mintFlex(
address(this),
amount,
deadline,
signatureNonce,
v,
r,
s
);
if (!success) revert MintFlexFailed();
unchecked {
totalEarned += amount;
}
emit WithdrawnToRealm(owner, amount, block.timestamp);
return true;
}
function withdrawFromBalance(
uint256 amount
) external onlyOwner nonReentrant returns (bool) {
if (amount == 0) revert ZeroAmount();
uint256 balance = IERC20(corexToken).balanceOf(address(this));
if (balance < amount) revert InsufficientBalance();
bool success = IERC20(corexToken).transfer(owner, amount);
if (!success) revert TransferFailed();
unchecked {
totalWithdrawn += amount;
}
emit WithdrawnFromBalance(owner, amount, block.timestamp);
return true;
}
function transfer(
address to,
uint256 amount
) external onlyOwner nonReentrant returns (bool) {
if (to == address(0)) revert ZeroAddress();
if (amount == 0) revert ZeroAmount();
uint256 balance = IERC20(corexToken).balanceOf(address(this));
if (balance < amount) revert InsufficientBalance();
bool success = IERC20(corexToken).transfer(to, amount);
if (!success) revert TransferFailed();
emit Transferred(owner, to, amount, block.timestamp);
return true;
}
function burn_award(
address tokenAddress
) external onlyChainverse nonReentrant {
if (tokenAddress == address(0)) revert ZeroAddress();
if (tokenAddress == corexToken) revert Unauthorized();
if (chainhole == address(0)) revert ZeroAddress();
(address burner, address receiver) = IInceChainhole(chainhole)
.getBurnRoles(address(this));
if (burner == address(0) || receiver == address(0)) {
revert ZeroAddress();
}
uint256 amount = IERC20(tokenAddress).balanceOf(burner);
if (amount == 0) revert ZeroAmount();
bool success = IERC20(tokenAddress).transferFrom(
burner,
receiver,
amount
);
if (!success) revert TransferFailed();
emit Burned(tokenAddress, amount, block.timestamp);
}
function getRealmInfo()
external
view
returns (
address _owner,
string memory _name,
string memory _metadata,
address _corexMiner,
address _corexToken,
address _chainhole,
address _chainverse
)
{
return (
owner,
name,
metadata,
corexMiner,
corexToken,
chainhole,
chainverse
);
}
function getBalanceInfo()
external
view
returns (
uint256 currentBalance,
uint256 _totalEarned,
uint256 _totalWithdrawn
)
{
return (
IERC20(corexToken).balanceOf(address(this)),
totalEarned,
totalWithdrawn
);
}
receive() external payable {
revert Unauthorized();
}
fallback() external payable {
revert Unauthorized();
}
}
EInceChainverse.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
// ============================================================================
// EInceChainverse - Shared custom errors
// Custom errors shared by chainverse / chainrealm of the Corex
// decentralized compute network (see CorexToken).
// ============================================================================
error ZeroAddress();
error Unauthorized();
error RealmAlreadyExists();
error SignatureExpired();
error InvalidSignature();
error DeadlineTooFar();
error AddressMismatch();
error ZeroAmount();
error InsufficientBalance();
error TransferFailed();
error MintFlexFailed();
error AlreadyInitialized();
IInceChainverse.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
/**
* @title IInceChainverse - External interfaces of the Corex compute network
* @author inceptum.cloud
* @notice Aggregated interface declarations for the core contracts of the
* Corex decentralized compute network referenced in the CorexToken:
* IcorexMiner, IInceChainverse, IInceChainrealm, IERC20.
* Used by per-node realms to obtain typed
* cross-contract references during settlement, registration and
* signature verification.
*/
interface IcorexMiner {
function registerFlexUser(
address user,
uint256 deadline,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) external;
function mintFlex(
address miner,
uint256 amount,
uint256 deadline,
bytes32 signatureNonce,
uint8 v,
bytes32 r,
bytes32 s
) external returns (bool);
function verifyRegisterFlexUserSignature(
address user,
uint256 deadline,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
) external view returns (bool isValid);
function verifyFlexMintSignature(
address flexUser,
address miner,
uint256 amount,
uint256 deadline,
bytes32 signatureNonce,
uint8 v,
bytes32 r,
bytes32 s
) external view returns (bool isValid);
function isFlexUser(address user) external view returns (bool);
}
interface IInceChainverse {
function executeBurn(address realmAddress, address tokenAddress) external;
}
interface IInceChainhole {
function registerRealm(address realm, address owner) external;
function getBurnRoles(
address realm
) external view returns (address burner, address receiver);
}
interface IInceChainrealm {
function burn_award(address tokenAddress) external;
function getRealmInfo()
external
view
returns (
address _owner,
string memory _name,
string memory _metadata,
address _corexMiner,
address _corexToken,
address _chainhole,
address _chainverse
);
function getBalanceInfo()
external
view
returns (
uint256 currentBalance,
uint256 _totalEarned,
uint256 _totalWithdrawn
);
}
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
inceChainverse.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import "./inceChainrealm.sol";
import "./IInceChainverse.sol";
import "./EInceChainverse.sol";
/**
* @title inceChainverse - Per-Node Compute-Realm Registry
* @author inceptum.cloud
* @notice Deploys a deterministic per-node chainrealm via CREATE2; each realm
* is the node's on-chain identity and settlement address within the
* node-tier & compute-reputation system
*/
contract inceChainverse {
address public immutable platformOwner;
IcorexMiner public immutable corexMiner;
address public immutable corexToken;
address public chainhole;
uint256 public constant MAX_SIGNATURE_VALIDITY = 1 hours;
bytes32 public constant SALT_PREFIX = keccak256("INCE_CHAINREALM");
mapping(address => address) public userRealms; // user => realm
mapping(address => bool) public deployedRealms; // realm => deployed
event RealmEstablished(
address indexed realmAddress,
address indexed owner,
string name,
uint256 timestamp
);
event RealmRegistered(address indexed realmAddress, uint256 timestamp);
event ChainholeSet(
address indexed oldChainhole,
address indexed newChainhole
);
event SignatureVerificationFailed(
address indexed user,
address indexed computedAddress,
uint256 timestamp
);
constructor(address _corexMiner, address _corexToken) {
if (_corexMiner == address(0)) revert ZeroAddress();
if (_corexToken == address(0)) revert ZeroAddress();
platformOwner = msg.sender;
corexMiner = IcorexMiner(_corexMiner);
corexToken = _corexToken;
chainhole = address(0);
}
function setChainhole(address _chainhole) external {
if (msg.sender != platformOwner) revert Unauthorized();
if (_chainhole == address(0)) revert ZeroAddress();
address oldChainhole = chainhole;
chainhole = _chainhole;
emit ChainholeSet(oldChainhole, _chainhole);
}
function establish(
string memory name,
string memory metadata,
uint256 registrationDeadline,
bytes32 registrationNonce,
uint8 v,
bytes32 r,
bytes32 s
) external returns (address realmAddress) {
address user = msg.sender;
if (chainhole == address(0)) revert ZeroAddress();
if (userRealms[user] != address(0)) revert RealmAlreadyExists();
if (user != tx.origin) revert Unauthorized();
if (block.timestamp > registrationDeadline) revert SignatureExpired();
if (registrationDeadline > block.timestamp + MAX_SIGNATURE_VALIDITY) {
revert DeadlineTooFar();
}
realmAddress = this.computeRealmAddress(user, name, metadata);
bool isSignatureValid = corexMiner.verifyRegisterFlexUserSignature(
realmAddress,
registrationDeadline,
registrationNonce,
v,
r,
s
);
if (!isSignatureValid) {
emit SignatureVerificationFailed(
user,
realmAddress,
block.timestamp
);
revert InvalidSignature();
}
corexMiner.registerFlexUser(
realmAddress,
registrationDeadline,
registrationNonce,
v,
r,
s
);
bytes32 salt = keccak256(abi.encodePacked(SALT_PREFIX, user));
address deployedAddress = address(
new inceChainrealm{salt: salt}(
user,
address(corexMiner),
corexToken,
chainhole,
name,
metadata
)
);
if (deployedAddress != realmAddress) revert AddressMismatch();
IInceChainhole(chainhole).registerRealm(realmAddress, user);
userRealms[user] = realmAddress;
deployedRealms[realmAddress] = true;
emit RealmEstablished(realmAddress, user, name, block.timestamp);
emit RealmRegistered(realmAddress, block.timestamp);
return realmAddress;
}
function executeBurn(address realmAddress, address tokenAddress) external {
if (msg.sender != chainhole) revert Unauthorized();
if (!deployedRealms[realmAddress]) revert Unauthorized();
IInceChainrealm(realmAddress).burn_award(tokenAddress);
}
function computeRealmAddress(
address user,
string memory name,
string memory metadata
) external view returns (address) {
bytes32 salt = keccak256(abi.encodePacked(SALT_PREFIX, user));
bytes32 bytecodeHash = keccak256(
abi.encodePacked(
type(inceChainrealm).creationCode,
abi.encode(
user,
address(corexMiner),
corexToken,
chainhole,
name,
metadata
)
)
);
bytes32 hash = keccak256(
abi.encodePacked(bytes1(0xff), address(this), salt, bytecodeHash)
);
return address(uint160(uint256(hash)));
}
function isValidRealm(address realmAddress) external view returns (bool) {
return deployedRealms[realmAddress];
}
function getUserRealm(address user) external view returns (address) {
return userRealms[user];
}
function getDeploymentStats()
external
view
returns (address userRealm, bool hasRealm)
{
userRealm = userRealms[msg.sender];
hasRealm = (userRealm != address(0));
}
function isRealmRegistered(address realm) external view returns (bool) {
return corexMiner.isFlexUser(realm);
}
}
Compiler settingsShow
{
"viaIR": true,
"optimizer": {
"runs": 10000,
"enabled": true
},
"evmVersion": "cancun"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.