Verified contractPartialUNLICENSED
CoinCodeRegistryV4
Address0xfcd5370f0b410ca1efab7e206ca94769b45cb1c1
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.30
- Same code
Only this contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- UNLICENSED
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,399,326
- Creation transaction
- 0x9ef9489ab5…bcfa2fb2e8
6 files
- src/v4/bridge/CoinCodeRegistryV4.solmain7.5 KB
- lib/openzeppelin-contracts/contracts/access/Ownable.sol3.1 KB
- lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol2.48 KB
- lib/openzeppelin-contracts/contracts/utils/Context.sol963 B
- src/v4/bridge/PangeaDeployerV4.sol2.04 KB
- src/v4/factory/CodeStoreV4.sol1.43 KB
src/v4/bridge/CoinCodeRegistryV4.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import {Ownable, Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {CodeStoreV4} from "../factory/CodeStoreV4.sol";
import {IPendingConfigV4} from "./PangeaDeployerV4.sol";
interface ICoinFactsV4 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function coinId() external view returns (bytes32);
function creatorAtLaunch() external view returns (address);
function bridge() external view returns (address);
function poolManager() external view returns (address);
}
/// @title CoinCodeRegistryV4 -- the append-only list of PangeaCoinV4 creation codes, IMMUTABLE (no proxy, no upgrade)
/// @notice UPGRADEABLE COIN CREATION (owner 2026-11-12): LaunchCoreV4 and CoinDeployerV4 sit behind UUPS proxies, so NEW
/// coins get new coin code by a new version here (and new open logic by a core upgrade); an EXISTING coin never
/// changes:
/// - a coin's code version is a pure function of its preimage `createdAt` (the same on every chain, Solana-home
/// coins included): the newest version whose `activeFrom` <= createdAt (`versionAt`). Version 0: activeFrom 0.
/// - versions are only APPENDED, each with activeFrom STRICTLY after the block it is added in (and after the
/// previous one). The bridge refuses createdAt > block.timestamp, so the version of every coin that is or can
/// be open anywhere can never change. No function changes or removes a recorded code.
/// - a coin's address on every chain is CREATE2(the coin-deployer PROXY, coinId, code[versionAt(createdAt)] ++
/// abi.encode(name, symbol, coinId, creatorAtLaunch)): an open-later of an old coin deploys its ORIGINAL code
/// at its one address, whatever the deployer / core have been upgraded to since.
/// - `genuine` is what the IMMUTABLE bridge asks before registering any token (BridgeRoleV4.registerCoin): the
/// token sits at exactly that address (so its code is the recorded version, built through the coin-deployer
/// proxy) and names this bridge and this chain's PoolManager. A hostile core / coin-deployer upgrade can
/// therefore never register a token of its own (mintable, re-pointed) for any coinId.
/// One address on every EVM chain (PangeaDeployerV4, fixed salt, init code without arguments; owner, coin-deployer
/// proxy and PoolManager via pending()). The same versions must be added on every chain with the same activeFrom:
/// `versionsHash` is then equal everywhere (VerifyBridgeV4 compares it to the build's version 0).
contract CoinCodeRegistryV4 is Ownable2Step {
struct Version {
address a; // first half of the creation code (CodeStoreV4 data contract)
address b; // second half
uint64 activeFrom;
bytes32 codeHash; // keccak256(creation code)
}
/// @notice The coin-deployer PROXY (the CREATE2 deployer of every coin on this chain).
address public immutable coinDeployer;
address public immutable poolManager;
Version[] internal _versions;
/// @notice keccak256 chain over every (codeHash, activeFrom) added, in order: equal on every chain when they agree.
bytes32 public versionsHash;
event VersionAdded(uint256 indexed version, bytes32 codeHash, uint64 activeFrom);
error BadActiveFrom(uint64 activeFrom);
error EmptyCode();
error NoVersion(uint64 createdAt);
error ZeroAddress();
constructor() Ownable(_pendingOwner()) {
(, address cd, address pm) = abi.decode(IPendingConfigV4(msg.sender).pending(), (address, address, address));
if (cd == address(0) || pm == address(0)) revert ZeroAddress();
coinDeployer = cd;
poolManager = pm;
}
function _pendingOwner() private view returns (address o) {
(o,,) = abi.decode(IPendingConfigV4(msg.sender).pending(), (address, address, address));
}
/// @notice Appends a coin creation code. The first version must have activeFrom 0; every later one an activeFrom
/// strictly after this block and after the previous version's.
function addVersion(bytes calldata code, uint64 activeFrom) external onlyOwner returns (uint256 v) {
if (code.length == 0) revert EmptyCode();
v = _versions.length;
if (v == 0) {
if (activeFrom != 0) revert BadActiveFrom(activeFrom);
} else if (activeFrom <= block.timestamp || activeFrom <= _versions[v - 1].activeFrom) {
revert BadActiveFrom(activeFrom);
}
(address a, address b) = CodeStoreV4.storeHalves(code);
bytes32 h = keccak256(code);
_versions.push(Version(a, b, activeFrom, h));
versionsHash = keccak256(abi.encode(versionsHash, h, activeFrom));
emit VersionAdded(v, h, activeFrom);
}
function versionCount() external view returns (uint256) {
return _versions.length;
}
function version(uint256 v) external view returns (Version memory) {
return _versions[v];
}
/// @notice The version of a coin created at `createdAt`: the newest with activeFrom <= createdAt.
function versionAt(uint64 createdAt) public view returns (uint256) {
uint256 n = _versions.length;
while (n != 0) {
if (_versions[n - 1].activeFrom <= createdAt) return n - 1;
n--;
}
revert NoVersion(createdAt);
}
/// @notice The creation code of version `v`, exactly as added.
function creationCode(uint256 v) public view returns (bytes memory code) {
Version storage x = _versions[v];
(address a, address b) = (x.a, x.b);
uint256 la = a.code.length - 1;
uint256 lb = b.code.length - 1;
code = new bytes(la + lb);
assembly ("memory-safe") {
extcodecopy(a, add(code, 32), 1, la)
extcodecopy(b, add(add(code, 32), la), 1, lb)
}
}
/// @notice The creation code a coin created at `createdAt` is deployed with.
function creationCodeAt(uint64 createdAt) external view returns (bytes memory) {
return creationCode(versionAt(createdAt));
}
/// @notice The one address of coin `coinId` (created at `createdAt`) on every EVM chain.
function tokenAddress(bytes32 coinId, string memory name, string memory symbol, address creatorAtLaunch, uint64 createdAt)
public
view
returns (address)
{
bytes32 h = keccak256(abi.encodePacked(creationCode(versionAt(createdAt)), abi.encode(name, symbol, coinId, creatorAtLaunch)));
return address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), coinDeployer, coinId, h)))));
}
/// @notice True only for the genuine coin `coinId` (created at `createdAt`) of `bridge_` on this chain: at its
/// recorded-version CREATE2 address under the coin-deployer proxy, naming `bridge_` and this PoolManager.
function genuine(address token, bytes32 coinId, address bridge_, uint64 createdAt) external view returns (bool) {
if (token.code.length == 0) return false;
ICoinFactsV4 t = ICoinFactsV4(token);
if (t.coinId() != coinId || t.bridge() != bridge_ || t.poolManager() != poolManager) return false;
return token == tokenAddress(coinId, t.name(), t.symbol(), t.creatorAtLaunch(), createdAt);
}
}
lib/openzeppelin-contracts/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);
}
}
lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
lib/openzeppelin-contracts/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/v4/bridge/PangeaDeployerV4.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
/// @notice What a v4 infra contract reads from its deployer in its constructor (the TokenDeployerV4 pattern, §11.2.1):
/// chain-specific values stay out of the init code, so the address is the same on every EVM chain.
interface IPendingConfigV4 {
function pending() external view returns (bytes memory);
}
/// @title PangeaDeployerV4 -- CREATE2 deployer of the shared-bridge infra (bridge, adapters, coin deployer, core)
/// @notice Itself deployed through the canonical CREATE2 deployer with a fixed salt and `initializer` (the same deploy
/// key / multisig in every config), so it has one address on every EVM chain, and so does everything it deploys
/// with the same salt and init code. Only `initializer` deploys; the per-chain config is handed over through
/// `pending()` for the duration of the constructor only.
contract PangeaDeployerV4 is IPendingConfigV4 {
address public immutable initializer;
bytes internal _pending;
event Deployed(bytes32 indexed salt, address indexed at);
error NotInitializer();
error DeployFailed();
constructor(address initializer_) {
initializer = initializer_;
}
function pending() external view returns (bytes memory) {
return _pending;
}
function predict(bytes32 salt, bytes calldata initcode) external view returns (address) {
return address(uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(initcode))))));
}
function deploy(bytes32 salt, bytes calldata initcode, bytes calldata config) external returns (address a) {
if (msg.sender != initializer) revert NotInitializer();
_pending = config;
bytes memory code = initcode;
assembly ("memory-safe") {
a := create2(0, add(code, 0x20), mload(code), salt)
}
delete _pending;
if (a == address(0)) revert DeployFailed();
emit Deployed(salt, a);
}
}
src/v4/factory/CodeStoreV4.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
/// @title CodeStoreV4 -- deploys bytes as the runtime code of a data contract (a STOP byte, then the bytes),
/// TokenDeployerV3's `_store`, as a library for the tests: the two halves of the PangeaOFTV4 and
/// PangeaOFTV4GapModule creation codes PangeaTokenDeployerV4 reads (each half under EIP-170's 24,576).
library CodeStoreV4 {
error CodeStoreFailed();
function store(bytes memory data) internal returns (address at) {
// PUSH4 len, DUP1, PUSH1 14, PUSH1 0, CODECOPY, PUSH1 0, RETURN -- then the runtime.
bytes memory init = abi.encodePacked(hex"63", uint32(data.length + 1), hex"80600e6000396000f3", hex"00", data);
assembly ("memory-safe") {
at := create(0, add(init, 32), mload(init))
}
if (at == address(0)) revert CodeStoreFailed();
}
/// @notice Store `code` in two halves; returns their addresses.
function storeHalves(bytes memory code) internal returns (address a, address b) {
uint256 la = code.length / 2;
uint256 lb = code.length - la;
bytes memory first = new bytes(la);
bytes memory second = new bytes(lb);
assembly ("memory-safe") {
mcopy(add(first, 32), add(code, 32), la)
mcopy(add(second, 32), add(add(code, 32), la), lb)
}
a = store(first);
b = store(second);
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@layerzerolabs/oft-evm/=lib/layerzero/oft-evm/",
"@layerzerolabs/oapp-evm/=lib/layerzero/oapp-evm/",
"@layerzerolabs/lz-evm-protocol-v2/=lib/layerzero/protocol-v2/",
"@uniswap/v4-core/=lib/uniswap-v4-core/",
"solmate/=lib/solmate/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"layerzero/=lib/layerzero/",
"uniswap-v4-core/=lib/uniswap-v4-core/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.