Authentication
Checking Origin Data
contract Target is IXReceiver {
/** @notice A modifier for authenticated calls.
* This is an important security consideration. If the target contract
* function should be authenticated, it must check three things:
* 1) The originating call comes from the expected origin domain.
* 2) The originating call comes from the expected source contract.
* 3) The call to this contract comes from Connext.
*/
modifier onlySource(address _originSender, uint32 _origin) {
require(
_origin == <ORIGIN_DOMAIN> &&
_originSender == <SOURCE_CONTRACT_ADDRESS> &&
msg.sender == <CONNEXT_CONTRACT_ADDRESS>,
"Expected source contract on origin domain called by Connext"
);
_;
}
function xReceive(
bytes32 _transferId,
uint256 _amount,
address _asset,
address _originSender,
uint32 _origin,
bytes memory _callData
) external onlySource(_originSender, _origin) returns (bytes memory) {
// Do stuff that requires authentication
}
}Last updated