Verified contractPartialMIT
adumChainverse
Address0xec4789bbe4e22ad99185426a5e1b9521c242a551
- Balance
0 ETH
- Transactions
115
- Compiler
solc 0.8.30
- Same code
Only this contract
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
- 24,877,963
- Creation transaction
- 0xa10dc5cc88…e862c5e71f
4 files
- adumChainverse.solmain5.5 KB
- EAdumChainverse.sol354 B
- IAdumChainverse.sol2.23 KB
- adumChainrealm.sol7.72 KB
adumChainverse.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import "./adumChainrealm.sol";
import "./IAdumChainverse.sol";
import "./EAdumChainverse.sol";
contract adumChainverse {
address public immutable platformOwner;
IcXMiner public immutable cXMiner;
address public immutable cXToken;
address public chainhole;
uint256 public constant MAX_SIGNATURE_VALIDITY = 1 hours;
bytes32 public constant SALT_PREFIX = keccak256("ADUM_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 _cXMiner, address _cXToken) {
if (_cXMiner == address(0)) revert ZeroAddress();
if (_cXToken == address(0)) revert ZeroAddress();
platformOwner = msg.sender;
cXMiner = IcXMiner(_cXMiner);
cXToken = _cXToken;
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 = cXMiner.verifyRegisterFlexUserSignature(
realmAddress,
registrationDeadline,
registrationNonce,
v,
r,
s
);
if (!isSignatureValid) {
emit SignatureVerificationFailed(
user,
realmAddress,
block.timestamp
);
revert InvalidSignature();
}
cXMiner.registerFlexUser(
realmAddress,
registrationDeadline,
registrationNonce,
v,
r,
s
);
bytes32 salt = keccak256(abi.encodePacked(SALT_PREFIX, user));
address deployedAddress = address(
new adumChainrealm{salt: salt}(
user,
address(cXMiner),
cXToken,
chainhole,
name,
metadata
)
);
if (deployedAddress != realmAddress) revert AddressMismatch();
IAdumChainhole(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();
IAdumChainrealm(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(adumChainrealm).creationCode,
abi.encode(
user,
address(cXMiner),
cXToken,
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 cXMiner.isFlexUser(realm);
}
}
EAdumChainverse.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
error ZeroAddress();
error Unauthorized();
error RealmAlreadyExists();
error SignatureExpired();
error InvalidSignature();
error DeadlineTooFar();
error AddressMismatch();
error ZeroAmount();
error InsufficientBalance();
error TransferFailed();
error MintFlexFailed();
error AlreadyInitialized();
IAdumChainverse.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
interface IcXMiner {
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 IAdumChainverse {
function executeBurn(address realmAddress, address tokenAddress) external;
}
interface IAdumChainhole {
function registerRealm(address realm, address owner) external;
function getBurnRoles(
address realm
) external view returns (address burner, address receiver);
}
interface IAdumChainrealm {
function burn_award(address tokenAddress) external;
function getRealmInfo()
external
view
returns (
address _owner,
string memory _name,
string memory _metadata,
address _cXMiner,
address _cXToken,
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);
}
adumChainrealm.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import "./IAdumChainverse.sol";
import "./EAdumChainverse.sol";
contract adumChainrealm {
address public immutable chainverse;
address public immutable owner;
address public immutable cXMiner;
address public immutable cXToken;
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 _cXMiner,
address _cXToken,
address _chainhole,
string memory _name,
string memory _metadata
) {
if (_owner == address(0)) revert ZeroAddress();
if (_cXMiner == address(0)) revert ZeroAddress();
if (_cXToken == address(0)) revert ZeroAddress();
if (_chainhole == address(0)) revert ZeroAddress();
chainverse = msg.sender;
owner = _owner;
cXMiner = _cXMiner;
cXToken = _cXToken;
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 = IcXMiner(cXMiner).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 = IcXMiner(cXMiner).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 = IcXMiner(cXMiner).verifyFlexMintSignature(
address(this),
address(this),
amount,
deadline,
signatureNonce,
v,
r,
s
);
if (!isSignatureValid) {
emit SignatureVerificationFailed(
owner,
address(this),
block.timestamp
);
revert InvalidSignature();
}
bool success = IcXMiner(cXMiner).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(cXToken).balanceOf(address(this));
if (balance < amount) revert InsufficientBalance();
bool success = IERC20(cXToken).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(cXToken).balanceOf(address(this));
if (balance < amount) revert InsufficientBalance();
bool success = IERC20(cXToken).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 == cXToken) revert Unauthorized();
if (chainhole == address(0)) revert ZeroAddress();
(address burner, address receiver) = IAdumChainhole(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 _cXMiner,
address _cXToken,
address _chainhole,
address _chainverse
)
{
return (
owner,
name,
metadata,
cXMiner,
cXToken,
chainhole,
chainverse
);
}
function getBalanceInfo()
external
view
returns (
uint256 currentBalance,
uint256 _totalEarned,
uint256 _totalWithdrawn
)
{
return (
IERC20(cXToken).balanceOf(address(this)),
totalEarned,
totalWithdrawn
);
}
receive() external payable {
revert Unauthorized();
}
fallback() external payable {
revert Unauthorized();
}
}
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.