Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/Salty.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
☞ https://ethos.vision
???? https://x.com/Ethereum_OS
✌︎ https://t.me/ethosportal
Welcome to the Ethereum Operating System — the first-of-its-kind revenue generating DeFi pumpware
built as a social DeFi sandbox that is filled with composable elements so you can create, trade,
communicate, and participate—all in one place.
@
@@:
@@@::
==@@@::::
===@@@:::::
===+@@+::::::
====@@@::::::::
=====@@@:::::::::
======@@@::::::::::
=======@@@:::::::::::
=======*@@+::::::::::::
========@@@::::::::::::::
==========@@@::::::::::::::::
===========@@@:::::::::::::::::
============@@@::::::::::::::::::
============*@@=:::::::::::::::::::
=============@@@:::::::::::::::::::::
=====@@@======@@@::::::::@@@:::::::::::
======@@@======@@@::::::::@@@::::::::::::
=======@@@======@@@::::::::@@@:::::::::::::
=================@@=:::::::::::::::::::::::::
==================%@@::::::::::::::::::::::::::::
===================@@@:::::::::::::::::::::::::::::
====================@@@::::::::::::::::::::::::::::::
=====================@@@:::::::::::::::::::::::::::::::
=====================+@@-::::::::::::::::::::::::::::::::
======================@@@@@@@@@@@@@@*::::::::::::::::::::::
=======================@@@@@@@@@@@@@@::::::::::::::::::::::::
===================================@@@:::::::::::::::::::::::::
=================================@@@:::::::::::::::::::::::
=========@@@@===================@@@::::::::@@@*::::::::::
=========@@@@@@@==============*@@:::::%@@@@@:::::::::::
===========@@@@@@@@@@@#*+=+*@@@@@@@@@@@-:::::::::::
==============+@@@@@@@@@@@@@@@@@@@:::::::::::::::
==========================@@@::::::::::::::::::
========================@@@::::::::::::::::
======================@@@::::::::::::::::
=====================@@@:::::::::::::::
===================@@@:::::::::::::
==================@@@::::::::::::
================*@@=:::::::::::
==============@@@::::::::::
=============@@@:::::::::
============@@@::::::::
==========@@#::::::
========@@@::::::
=======@@@:::::
=====@@@:::
====@@@::
==*@@-:
=@@@:
@
@@@
@@@@@@@@@@@@@@@@@@@ @@@@@@@ ======= ========
@@@@@@@@@@@@@@@@@@ @@@@@ ==== ===== ===== =====
@@@@@ @@ @@@@ ===== ==== ==== ===
@@@@@ @ @@@@ ==== ===== ==== ===
@@@@@ @@@@ ==== ===== ==== ==
@@@@@ @@ @@@@ ===== ===== =====
@@@@@ @ @@@@ @@@@ @ ===== ===== =======
@@@@@ @@ @@@@@@@@@@@@ @@@@ @@@@@@@@ ===== ===== =========
@@@@@@@@@@@@@ @@@@ @@@@@@ @@@@@ ===== ===== =========
@@@@@ @@ @@@@ @@@@@ @@@@@ ===== ===== =========
@@@@@ @@ @@@@ @@@@ @@@@ ===== ===== ========
@@@@@ @@@@ @@@@ @@@@ ====== ===== ======
@@@@@ @@@@ @@@@ @@@@ ===== ===== =====
@@@@@ @@@@ @@@@ @@@@ ===== ===== == =====
@@@@@ @@ @@@@ @@@@ @@@@ ==== ===== === =====
@@@@@ @@@ @@@@@ @@@@ @@@@ ===== ==== ==== ====
@@@@@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@ @@@@@@ ===== ==== ===== =====
@@@@@@@@@@@@@@@@@@@@ @@@@@@ @@@@@@@@@ @@@@@@@@@ ========== =========
*/
contract SaltExpert {
function calculateSalt(bytes memory baseCreationCode, string memory name, string memory symbol, address _ethOs, address _deployer) public view returns (bytes32) {
uint8 thirdLastNibble = 0xE; // Lower nibble of second-last byte
uint8 secondLastNibble = 0x0; // Upper nibble of last byte
uint8 lastNibble = 0x5; // Lower nibble of last byte
// Append encoded constructor args to form full initCode
bytes memory initCode = abi.encodePacked(
baseCreationCode,
abi.encode(name, symbol, _ethOs)
);
bytes32 initCodeHash = keccak256(initCode);
uint256 saltValue = 0;
address predicted;
while (true) {
// Compute predicted address for this salt
bytes32 data = keccak256(abi.encodePacked(bytes1(0xff), _deployer, saltValue, initCodeHash));
predicted = address(uint160(uint256(data)));
// Extract bytes for suffix check
bytes20 addrBytes = bytes20(predicted);
// Check last 3 hex digits via nibbles
uint8 byte18Lower = uint8(addrBytes[18] & 0x0F); // Third-last hex char
uint8 byte19Upper = uint8(addrBytes[19] >> 4); // Second-last hex char
uint8 byte19Lower = uint8(addrBytes[19] & 0x0F); // Last hex char
if (byte18Lower == thirdLastNibble &&
byte19Upper == secondLastNibble &&
byte19Lower == lastNibble) {
// Compute EIP-55 checksum hash for case check
bytes memory lowerHex = toLowerHex(predicted);
bytes32 checksumHash = keccak256(lowerHex);
// Check nibble for position 37 (third-last hex digit): low nibble of byte 18 in hash
uint8 nibble37 = uint8(checksumHash[18]) & 0x0F;
if (nibble37 >= 8) {
// Check if the address is free (no code and no balance)
if (predicted.code.length == 0 && predicted.balance == 0) {
return bytes32(saltValue); // 'E' will be uppercase in checksum and address is available
}
}
// If <8 (would be lowercase 'e') or occupied, continue searching
}
saltValue++; // Increment salt
if (saltValue > 10_000_000) {
revert("No suitable salt found within limit"); // Prevent infinite loop/gas exhaustion
}
}
}
function toLowerHex(address addr) internal pure returns (bytes memory) {
bytes memory hexStr = new bytes(40);
uint160 a = uint160(addr);
for (uint256 i = 0; i < 20; i++) {
uint8 b = uint8(a >> (152 - i * 8)); // Extract byte from left
uint8 high = b >> 4;
uint8 low = b & 0x0F;
hexStr[i * 2] = high < 10 ? bytes1(high + 48) : bytes1(high + 87); // '0'-'9', 'a'-'f'
hexStr[i * 2 + 1] = low < 10 ? bytes1(low + 48) : bytes1(low + 87);
}
return hexStr;
}
}"
}
},
"settings": {
"remappings": [
"forge-std/=lib/forge-std/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@uniswap/=lib/universal-router/node_modules/@uniswap/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"permit2/=lib/permit2/",
"solmate/=lib/universal-router/lib/solmate/",
"universal-router/=lib/universal-router/",
"v4-core/=lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false
}
}}
Submitted on: 2025-09-17 16:17:06
Comments
Log in to comment.
No comments yet.