Blockchain / Global / Address

Contract

0xBf05BdaFf9b80CF511f89069410af2d7B1897471

Balance
0 SOMI
Transactions sent
1
Type
Contract · 1,686 bytes of code

RelayReceiver Verified

Compiler
solc 0.8.30+commit.73712a01
Language
Solidity
Optimization
No
EVM version
cancun
License
—
Verified
2026-10-12

src/v1/RelayReceiver.sol

Solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

contract RelayReceiver {
    // --- Structs ---

    struct Call {
        address to;
        bytes data;
        uint256 value;
    }

    // --- Errors ---

    error CallFailed();
    error NativeTransferFailed();
    error Unauthorized();

    // --- Events ---

    event FundsForwardedWithData(bytes data);

    // --- Fields ---

    address private immutable SOLVER;

    // --- Constructor ---

    constructor(address solver) {
        SOLVER = solver;
    }

    // --- Public methods ---

    fallback() external payable {
        send(SOLVER, msg.value);
        emit FundsForwardedWithData(msg.data);
    }

    function forward(bytes calldata data) external payable {
        send(SOLVER, msg.value);
        emit FundsForwardedWithData(data);
    }

    // --- Restricted methods ---

    function makeCalls(Call[] calldata calls) external payable {
        if (msg.sender != SOLVER) {
            revert Unauthorized();
        }

        unchecked {
            uint256 length = calls.length;
            for (uint256 i; i < length; i++) {
                Call memory c = calls[i];

                (bool success, ) = c.to.call{value: c.value}(c.data);
                if (!success) {
                    revert CallFailed();
                }
            }
        }
    }

    // --- Internal methods ---

    function send(address to, uint256 value) internal {
        bool success;
        assembly {
            // Save gas by avoiding copying the return data to memory.
            // Provide at most 100k gas to the internal call, which is
            // more than enough to cover common use-cases of logic for
            // receiving native tokens (eg. SCW payable fallbacks).
            success := call(100000, to, value, 0, 0, 0, 0)
        }

        if (!success) {
            revert NativeTransferFailed();
        }
    }
}
ABI · 8 entries
json
[
  {
    "type": "constructor",
    "inputs": [
      {
        "name": "solver",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "name": "CallFailed",
    "type": "error",
    "inputs": []
  },
  {
    "name": "NativeTransferFailed",
    "type": "error",
    "inputs": []
  },
  {
    "name": "Unauthorized",
    "type": "error",
    "inputs": []
  },
  {
    "name": "FundsForwardedWithData",
    "type": "event",
    "inputs": [
      {
        "name": "data",
        "type": "bytes",
        "indexed": false,
        "internalType": "bytes"
      }
    ],
    "anonymous": false
  },
  {
    "type": "fallback",
    "stateMutability": "payable"
  },
  {
    "name": "forward",
    "type": "function",
    "inputs": [
      {
        "name": "data",
        "type": "bytes",
        "internalType": "bytes"
      }
    ],
    "outputs": [],
    "stateMutability": "payable"
  },
  {
    "name": "makeCalls",
    "type": "function",
    "inputs": [
      {
        "name": "calls",
        "type": "tuple[]",
        "components": [
          {
            "name": "to",
            "type": "address",
            "internalType": "address"
          },
          {
            "name": "data",
            "type": "bytes",
            "internalType": "bytes"
          },
          {
            "name": "value",
            "type": "uint256",
            "internalType": "uint256"
          }
        ],
        "internalType": "struct RelayReceiver.Call[]"
      }
    ],
    "outputs": [],
    "stateMutability": "payable"
  }
]