ETH Price: $4,173.51 (-0.70%)

Contract

0xc5C38A15A9D3D9dC5Fc7dE4426779B695677e45D

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

N/A
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SwitchboardPlug

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {ISocket} from "../interfaces/ISocket.sol";
import {ISwitchboardRouter} from "../interfaces/ISwitchboardRouter.sol";
import {ISwitchboardPlug} from "../interfaces/ISwitchboardPlug.sol";
import {IPlug} from "../interfaces/IPlug.sol";
import {NotSocket, NotSwitchboardRouter} from "../common/Errors.sol";

/// @title SwitchboardPlug
/// @notice Plugs are application that can communicate across chains on Socket DL
/// @notice SwitchboardPlug is a plug that can via a specific Switchboard on Socket DL
contract SwitchboardPlug is IPlug, ISwitchboardPlug {
    /*//////////////////////////////////////////////////////////////////////////
                                PUBLIC STORAGE
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Socket contract - Settlement layer
    ISocket public immutable SOCKET;

    /// @notice SwitchboardRouter contract
    ISwitchboardRouter public immutable SWITCHBOARD_ROUTER;

    /// @notice SwitchboardId assigned to this SwitchboardPlug
    uint32 public immutable SWITCHBOARD_ID;

    /// @notice address of switchboard which will validate the incoming messages to the current chain
    address public immutable INBOUND_SWITCHBOARD;

    /// @notice address of switchboard which will process outgoing messages to the siblingChain
    address public immutable OUTBOUND_SWITCHBOARD;

    /// @notice maps siblingChainSlug to bool to indicate if that chain is already configured
    mapping(uint32 siblingChainSlug => bool configured) public isConfigured;

    constructor(
        address _socket,
        address _switchboardRouter,
        address _inboundSwitchboard,
        address _outboundSwitchboard,
        uint32 _switchboardId
    ) {
        SOCKET = ISocket(_socket);
        SWITCHBOARD_ROUTER = ISwitchboardRouter(_switchboardRouter);
        INBOUND_SWITCHBOARD = _inboundSwitchboard;
        OUTBOUND_SWITCHBOARD = _outboundSwitchboard;
        SWITCHBOARD_ID = _switchboardId;
    }

    /*//////////////////////////////////////////////////////////////////////////
                            EXTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice Calls Socket to initialize connection with sibling switchboardPlug to send/receive messages
    /// @param siblingChainSlug chainSlug of the sibling chain
    /// @param siblingPlug address of the sibling Plug
    function connect(uint32 siblingChainSlug, address siblingPlug) external {
        // checks if the caller is Switchboard Router
        _checkIfSwitchboardRouter();

        // stores connection status
        isConfigured[siblingChainSlug] = true;

        // calls Socket to initialise connection
        SOCKET.connect(siblingChainSlug, siblingPlug, INBOUND_SWITCHBOARD, OUTBOUND_SWITCHBOARD);
    }

    /// @notice Called by SwitchboardRouter to send outgoing settlement messages
    /// @param siblingChainSlug chainSlug of the sibling chain the message is to be sent to
    /// @param msgGasLimit gasLimit required to execute the message on the sibling chain
    /// @param payload payload to be executed on the sibling chain
    function outbound(uint32 siblingChainSlug, uint256 msgGasLimit, bytes calldata payload) external payable {
        // checks if the caller is Switchboard Router
        _checkIfSwitchboardRouter();

        // sends message to Socket
        /// @dev bytes32(0) indicates fast finality transmission
        SOCKET.outbound{value: msg.value}(siblingChainSlug, msgGasLimit, bytes32(0), bytes32(0), payload);
    }

    /// @notice Called by Socket to receive incoming messages on the destination chain
    /// @param siblingChainSlug chainSlug of the chain the message originated from
    /// @param payload payload sent from the originating chain
    function inbound(uint32 siblingChainSlug, bytes calldata payload) external payable {
        // checks if the caller is Socket
        _checkIfSocket();

        // Calls SwitchboardRouter with the incoming message
        SWITCHBOARD_ROUTER.receiveAndDeliverMsg(SWITCHBOARD_ID, siblingChainSlug, payload);
    }

    /*//////////////////////////////////////////////////////////////////////////
                            INTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////////////////*/

    /// @notice checks if caller is Switchboard Router
    function _checkIfSwitchboardRouter() internal view {
        if (msg.sender != address(SWITCHBOARD_ROUTER)) revert NotSwitchboardRouter();
    }

    /// @notice checks if caller is Socket
    function _checkIfSocket() internal view {
        if (msg.sender != address(SOCKET)) revert NotSocket();
    }
}

File 2 of 6 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/*//////////////////////////////////////////////////////////////
                         BUNGEE ERRORS
//////////////////////////////////////////////////////////////*/

error MofaSignatureInvalid();
error InsufficientNativeAmount();
error UnsupportedRequest();
error RouterNotRegistered();
error CallerNotBungeeGateway();
error CallerNotEntrypoint();
error SwapOutputInsufficient();
error MinOutputNotMet();
error InvalidRequest();
error FulfilmentDeadlineNotMet();
error CallerNotDelegate();
error CallerNotStakedRouter();
error InvalidMsg();
error RequestProcessed();
error RequestNotProcessed();
error InvalidSwitchboard();
error PromisedAmountNotMet();
error MsgReceiveFailed();
error RouterAlreadyRegistered();
error InvalidFulfil();
error NotImplemented();
error OnlyOwner();
error OnlyNominee();
error InvalidReceiver();
error ImplAlreadyRegistered();
error InvalidAddress();
error ActionFailed();
error InvalidDstEid();
error SwapInputExceedsAllowance();

/*//////////////////////////////////////////////////////////////
                       SWITCHBOARD ERRORS
//////////////////////////////////////////////////////////////*/

error NotSiblingBungeeGateway();
error NotSocket();
error NotSwitchboardRouter();
error NotSwitchboardPlug();
error SwitchboardPlugZero();
error ConnectionAlreadyInitialised();
error IncorrectSwitchboard();

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/**
 * @title IPlug
 * @notice Interface for a plug contract that executes the message received from a source chain.
 */
interface IPlug {
    /**
     * @dev this should be only executable by socket
     * @notice executes the message received from source chain
     * @notice It is expected to have original sender checks in the destination plugs using payload
     * @param srcChainSlug_ chain slug of source
     * @param payload_ the data which is needed by plug at inbound call on remote
     */
    function inbound(uint32 srcChainSlug_, bytes calldata payload_) external payable;
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.19;

interface ISocketConfig {
    function getPlugConfig(
        address plugAddress_,
        uint32 siblingChainSlug_
    )
        external
        view
        returns (
            address siblingPlug,
            address inboundSwitchboard__,
            address outboundSwitchboard__,
            address capacitor__,
            address decapacitor__
        );
}

/**
 * @title ISocket
 * @notice An interface for a cross-chain communication contract
 * @dev This interface provides methods for transmitting and executing messages between chains,
 * connecting a plug to a remote chain and setting up switchboards for the message transmission
 * This interface also emits events for important operations such as message transmission, execution status,
 * and plug connection
 */
interface ISocket is ISocketConfig {
    /**
     * @notice registers a message
     * @dev Packs the message and includes it in a packet with capacitor
     * @param remoteChainSlug_ the remote chain slug
     * @param minMsgGasLimit_ the gas limit needed to execute the payload on remote
     * @param payload_ the data which is needed by plug at inbound call on remote
     */
    function outbound(
        uint32 remoteChainSlug_,
        uint256 minMsgGasLimit_,
        bytes32 executionParams_,
        bytes32 transmissionParams_,
        bytes calldata payload_
    ) external payable returns (bytes32 msgId);

    /**
     * @notice sets the config specific to the plug
     * @param siblingChainSlug_ the sibling chain slug
     * @param siblingPlug_ address of plug present at sibling chain to call inbound
     * @param inboundSwitchboard_ the address of switchboard to use for receiving messages
     * @param outboundSwitchboard_ the address of switchboard to use for sending messages
     */
    function connect(
        uint32 siblingChainSlug_,
        address siblingPlug_,
        address inboundSwitchboard_,
        address outboundSwitchboard_
    ) external;

    event PlugConnected(
        address plug,
        uint32 siblingChainSlug,
        address siblingPlug,
        address inboundSwitchboard,
        address outboundSwitchboard,
        address capacitor,
        address decapacitor
    );
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

import {IPlug} from "./IPlug.sol";

interface ISwitchboardPlug is IPlug {
    function SWITCHBOARD_ID() external view returns (uint32);

    function connect(uint32 siblingChainSlug, address siblingPlug) external;

    function outbound(uint32 siblingChainSlug, uint256 msgGasLimit, bytes calldata payload) external payable;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;

interface ISwitchboardRouter {
    function sendOutboundMsg(
        uint32 originChainId,
        uint32 switchboardId,
        uint8 msgId,
        uint256 destGasLimit,
        bytes calldata payload
    ) external payable;

    function receiveAndDeliverMsg(uint32 switchboardId, uint32 siblingChainId, bytes calldata payload) external;
}

Settings
{
  "libraries": {},
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_socket","type":"address"},{"internalType":"address","name":"_switchboardRouter","type":"address"},{"internalType":"address","name":"_inboundSwitchboard","type":"address"},{"internalType":"address","name":"_outboundSwitchboard","type":"address"},{"internalType":"uint32","name":"_switchboardId","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"NotSocket","type":"error"},{"inputs":[],"name":"NotSwitchboardRouter","type":"error"},{"inputs":[],"name":"INBOUND_SWITCHBOARD","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OUTBOUND_SWITCHBOARD","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SOCKET","outputs":[{"internalType":"contract ISocket","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SWITCHBOARD_ID","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SWITCHBOARD_ROUTER","outputs":[{"internalType":"contract ISwitchboardRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"siblingChainSlug","type":"uint32"},{"internalType":"address","name":"siblingPlug","type":"address"}],"name":"connect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"siblingChainSlug","type":"uint32"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"inbound","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint32","name":"siblingChainSlug","type":"uint32"}],"name":"isConfigured","outputs":[{"internalType":"bool","name":"configured","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"siblingChainSlug","type":"uint32"},{"internalType":"uint256","name":"msgGasLimit","type":"uint256"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"outbound","outputs":[],"stateMutability":"payable","type":"function"}]

61012060405234801561001157600080fd5b506040516108fe3803806108fe8339810160408190526100309161007b565b6001600160a01b0394851660805292841660a05290831660e0529091166101005263ffffffff1660c0526100ed565b80516001600160a01b038116811461007657600080fd5b919050565b600080600080600060a0868803121561009357600080fd5b61009c8661005f565b94506100aa6020870161005f565b93506100b86040870161005f565b92506100c66060870161005f565b9150608086015163ffffffff811681146100df57600080fd5b809150509295509295909350565b60805160a05160c05160e051610100516107966101686000396000818160b2015261036b0152600081816102270152610343015260008181610177015261043f0152600081816101030152818161041201526104af0152600081816101f3015281816102680152818161039301526104fa01526107966000f3fe6080604052600436106100865760003560e01c8063883dbe0211610059578063883dbe02146101655780638ec4a6e7146101ae578063c41f1f6c146101ce578063d2954f9a146101e1578063d41471ac1461021557600080fd5b80630293f6971461008b5780630a5415e6146100a05780630e4bfd6e146100f15780635ecd1ca614610125575b600080fd5b61009e61009936600461059a565b610249565b005b3480156100ac57600080fd5b506100d47f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100fd57600080fd5b506100d47f000000000000000000000000000000000000000000000000000000000000000081565b34801561013157600080fd5b506101556101403660046105f4565b60006020819052908152604090205460ff1681565b60405190151581526020016100e8565b34801561017157600080fd5b506101997f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff90911681526020016100e8565b3480156101ba57600080fd5b5061009e6101c9366004610616565b6102f4565b61009e6101dc366004610659565b6103f3565b3480156101ed57600080fd5b506100d47f000000000000000000000000000000000000000000000000000000000000000081565b34801561022157600080fd5b506100d47f000000000000000000000000000000000000000000000000000000000000000081565b6102516104a4565b604051633386774f60e01b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633386774f9034906102aa908890889060009081908a908a906004016106d5565b60206040518083038185885af11580156102c8573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906102ed9190610713565b5050505050565b6102fc6104a4565b63ffffffff821660008181526020819052604090819020805460ff19166001179055516307637ccf60e31b815260048101919091526001600160a01b0382811660248301527f0000000000000000000000000000000000000000000000000000000000000000811660448301527f0000000000000000000000000000000000000000000000000000000000000000811660648301527f00000000000000000000000000000000000000000000000000000000000000001690633b1be67890608401600060405180830381600087803b1580156103d757600080fd5b505af11580156103eb573d6000803e3d6000fd5b505050505050565b6103fb6104ef565b604051634078888360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063407888839061046d907f00000000000000000000000000000000000000000000000000000000000000009087908790879060040161072c565b600060405180830381600087803b15801561048757600080fd5b505af115801561049b573d6000803e3d6000fd5b50505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146104ed576040516365dc0c7760e11b815260040160405180910390fd5b565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146104ed57604051633167e3df60e21b815260040160405180910390fd5b803563ffffffff8116811461054c57600080fd5b919050565b60008083601f84011261056357600080fd5b50813567ffffffffffffffff81111561057b57600080fd5b60208301915083602082850101111561059357600080fd5b9250929050565b600080600080606085870312156105b057600080fd5b6105b985610538565b935060208501359250604085013567ffffffffffffffff8111156105dc57600080fd5b6105e887828801610551565b95989497509550505050565b60006020828403121561060657600080fd5b61060f82610538565b9392505050565b6000806040838503121561062957600080fd5b61063283610538565b915060208301356001600160a01b038116811461064e57600080fd5b809150509250929050565b60008060006040848603121561066e57600080fd5b61067784610538565b9250602084013567ffffffffffffffff81111561069357600080fd5b61069f86828701610551565b9497909650939450505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b63ffffffff8716815285602082015284604082015283606082015260a06080820152600061070760a0830184866106ac565b98975050505050505050565b60006020828403121561072557600080fd5b5051919050565b600063ffffffff8087168352808616602084015250606060408301526107566060830184866106ac565b969550505050505056fea2646970667358221220bc01e7cab613f6502b436fd1d6919682c0894511d62180ac7df1e035e1121dc364736f6c634300081300330000000000000000000000000cc93650bf4d98237628dacf87f94e443956d8df0000000000000000000000003416dabeaf259fbe5ba455e361f23e58bab91e3e000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef0000000000000000000000000000000000000000000000000000000000000001

Deployed Bytecode

0x6080604052600436106100865760003560e01c8063883dbe0211610059578063883dbe02146101655780638ec4a6e7146101ae578063c41f1f6c146101ce578063d2954f9a146101e1578063d41471ac1461021557600080fd5b80630293f6971461008b5780630a5415e6146100a05780630e4bfd6e146100f15780635ecd1ca614610125575b600080fd5b61009e61009936600461059a565b610249565b005b3480156100ac57600080fd5b506100d47f000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef81565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100fd57600080fd5b506100d47f0000000000000000000000003416dabeaf259fbe5ba455e361f23e58bab91e3e81565b34801561013157600080fd5b506101556101403660046105f4565b60006020819052908152604090205460ff1681565b60405190151581526020016100e8565b34801561017157600080fd5b506101997f000000000000000000000000000000000000000000000000000000000000000181565b60405163ffffffff90911681526020016100e8565b3480156101ba57600080fd5b5061009e6101c9366004610616565b6102f4565b61009e6101dc366004610659565b6103f3565b3480156101ed57600080fd5b506100d47f0000000000000000000000000cc93650bf4d98237628dacf87f94e443956d8df81565b34801561022157600080fd5b506100d47f000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef81565b6102516104a4565b604051633386774f60e01b81526001600160a01b037f0000000000000000000000000cc93650bf4d98237628dacf87f94e443956d8df1690633386774f9034906102aa908890889060009081908a908a906004016106d5565b60206040518083038185885af11580156102c8573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906102ed9190610713565b5050505050565b6102fc6104a4565b63ffffffff821660008181526020819052604090819020805460ff19166001179055516307637ccf60e31b815260048101919091526001600160a01b0382811660248301527f000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef811660448301527f000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef811660648301527f0000000000000000000000000cc93650bf4d98237628dacf87f94e443956d8df1690633b1be67890608401600060405180830381600087803b1580156103d757600080fd5b505af11580156103eb573d6000803e3d6000fd5b505050505050565b6103fb6104ef565b604051634078888360e01b81526001600160a01b037f0000000000000000000000003416dabeaf259fbe5ba455e361f23e58bab91e3e169063407888839061046d907f00000000000000000000000000000000000000000000000000000000000000019087908790879060040161072c565b600060405180830381600087803b15801561048757600080fd5b505af115801561049b573d6000803e3d6000fd5b50505050505050565b336001600160a01b037f0000000000000000000000003416dabeaf259fbe5ba455e361f23e58bab91e3e16146104ed576040516365dc0c7760e11b815260040160405180910390fd5b565b336001600160a01b037f0000000000000000000000000cc93650bf4d98237628dacf87f94e443956d8df16146104ed57604051633167e3df60e21b815260040160405180910390fd5b803563ffffffff8116811461054c57600080fd5b919050565b60008083601f84011261056357600080fd5b50813567ffffffffffffffff81111561057b57600080fd5b60208301915083602082850101111561059357600080fd5b9250929050565b600080600080606085870312156105b057600080fd5b6105b985610538565b935060208501359250604085013567ffffffffffffffff8111156105dc57600080fd5b6105e887828801610551565b95989497509550505050565b60006020828403121561060657600080fd5b61060f82610538565b9392505050565b6000806040838503121561062957600080fd5b61063283610538565b915060208301356001600160a01b038116811461064e57600080fd5b809150509250929050565b60008060006040848603121561066e57600080fd5b61067784610538565b9250602084013567ffffffffffffffff81111561069357600080fd5b61069f86828701610551565b9497909650939450505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b63ffffffff8716815285602082015284604082015283606082015260a06080820152600061070760a0830184866106ac565b98975050505050505050565b60006020828403121561072557600080fd5b5051919050565b600063ffffffff8087168352808616602084015250606060408301526107566060830184866106ac565b969550505050505056fea2646970667358221220bc01e7cab613f6502b436fd1d6919682c0894511d62180ac7df1e035e1121dc364736f6c63430008130033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000000cc93650bf4d98237628dacf87f94e443956d8df0000000000000000000000003416dabeaf259fbe5ba455e361f23e58bab91e3e000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef0000000000000000000000000000000000000000000000000000000000000001

-----Decoded View---------------
Arg [0] : _socket (address): 0x0CC93650bF4D98237628DACf87f94E443956D8dF
Arg [1] : _switchboardRouter (address): 0x3416daBEAf259FBE5ba455E361f23e58BAB91E3E
Arg [2] : _inboundSwitchboard (address): 0x525a6489a1df5fF1ae077fAf628E43b7F52298eF
Arg [3] : _outboundSwitchboard (address): 0x525a6489a1df5fF1ae077fAf628E43b7F52298eF
Arg [4] : _switchboardId (uint32): 1

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000000cc93650bf4d98237628dacf87f94e443956d8df
Arg [1] : 0000000000000000000000003416dabeaf259fbe5ba455e361f23e58bab91e3e
Arg [2] : 000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef
Arg [3] : 000000000000000000000000525a6489a1df5ff1ae077faf628e43b7f52298ef
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000001


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.