Description:
Smart contract deployed on Ethereum with Factory features.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/TransferToMesonContract.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
interface IMesonMinimal {
function simpleExecuteSwap(uint256 encodedSwap) payable external;
}
contract TransferToMesonFactory {
function deploy(address mesonAddress, address initiator, uint16 destinationChain, bytes32 destinationAddress) external returns (address deployedAddress) {
bytes memory bytecode = abi.encodePacked(
type(TransferToMesonContract).creationCode,
abi.encode(mesonAddress, initiator, destinationChain, destinationAddress)
);
assembly {
deployedAddress := create2(0, add(bytecode, 32), mload(bytecode), "")
if iszero(deployedAddress) {
revert(0, 0)
}
}
}
}
contract TransferToMesonContract {
bytes4 private constant ERC20_APPROVE_SELECTOR = bytes4(keccak256("approve(address,uint256)"));
IMesonMinimal public immutable meson;
address public immutable initiator;
uint16 public immutable destinationChain;
bytes32 public immutable destinationAddress; // Could be used for non-EVMs
constructor(address mesonAddress, address _initiator, uint16 _destinationChain, bytes32 _destinationAddress) {
meson = IMesonMinimal(mesonAddress);
initiator = _initiator;
destinationChain = _destinationChain;
destinationAddress = _destinationAddress;
}
function approve(address tokenAddr, uint256 amount) external {
require(msg.sender == initiator, "Unauthorized");
(bool success, bytes memory data) = tokenAddr.call(
abi.encodeWithSelector(ERC20_APPROVE_SELECTOR, address(meson), amount)
);
require(success && (data.length == 0 || abi.decode(data, (bool))));
}
function transferToMeson(uint256 encodedSwap) external {
require(msg.sender == initiator, "Unauthorized");
require((destinationChain == 0xFFFF) || (destinationChain == uint16(encodedSwap >> 32)), "Incorrect destination chain");
uint8 tokenIndex = uint8(encodedSwap);
if ((tokenIndex >= 49 && tokenIndex <= 64) || ((tokenIndex > 190) && ((tokenIndex % 4) == 3))) {
// core/gas token
uint256 amount = ((encodedSwap >> 208) & 0xFFFFFFFFFF) * 10 ** 12;
meson.simpleExecuteSwap{value: amount}(encodedSwap);
} else {
meson.simpleExecuteSwap(encodedSwap);
}
}
}
"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 100
},
"evmVersion": "istanbul",
"viaIR": true,
"metadata": {
"bytecodeHash": "none"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
}
}
}}
Submitted on: 2025-10-04 19:00:05
Comments
Log in to comment.
No comments yet.