Discover more of Apescan's tools and services in one place.
Contract Source Code:
File 1 of 1 : CoreRouter.sol
// SPDX-License-Identifier: MIT pragma solidity 0.8.19; /// @title Cyan Wallet Core Router - A Cyan wallet's core router. /// @author Bulgantamir Gankhuyag - <[email protected]> /// @author Naranbayar Uuganbayar - <[email protected]> contract CoreRouter { address payable private immutable _this; address private _admin; address private _core; event SetRouterAdmin(address admin); event SetCore(address core); modifier onlyAdmin() { require(_admin == msg.sender, "Caller is not an admin."); _; } /// @notice Prevents non delegatecall into the modified method modifier onlyDelegateCall() { require(address(this) != _this, "Cannot be called directly."); _; } constructor(address core) { require(core != address(0x0), "Invalid core address."); _admin = msg.sender; _core = core; _this = payable(address(this)); } /// @notice Changes the admin of the router. /// @param admin Address of the new admin. function setRouterAdmin(address admin) external onlyAdmin { require(admin != address(0x0), "Invalid admin address."); _admin = admin; emit SetRouterAdmin(admin); } /// @notice Returns an admin address of the router. /// @return Address of the current admin. function getRouterAdmin() external view returns (address) { return _admin; } /// @notice Changes the address of the core contract. /// Note: Changing the core address will affect to all wallets. /// @param core Address of the new core contract. function setCore(address core) external onlyAdmin { require(core != address(0x0), "Invalid core address."); _core = core; emit SetCore(core); } /// @notice Returns the address of the core contract. /// @return Address of the current core contract. function getCore() external view returns (address) { if (_this == address(this)) { return _core; } else { return CoreRouter(_this).getCore(); } } /// @notice Delegates all transcations to the core contract. fallback() external payable onlyDelegateCall { address core = CoreRouter(_this).getCore(); assembly { calldatacopy(0, 0, calldatasize()) let success := delegatecall(gas(), core, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) if eq(success, 0) { revert(0, returndatasize()) } return(0, returndatasize()) } } }
Please enter a contract address above to load the contract details and source code.
Please DO NOT store any passwords or private keys here. A private note (up to 100 characters) can be saved and is useful for transaction tracking.
This website uses cookies to improve your experience. By continuing to use this website, you agree to its Terms and Privacy Policy.