文件 1 的 1:FlashbotsCheckAndSend.sol
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
contract FlashbotsCheckAndSend {
function check32BytesAndSend(address _target, bytes memory _payload, bytes32 _resultMatch) external payable {
_check32Bytes(_target, _payload, _resultMatch);
block.coinbase.transfer(msg.value);
}
function check32BytesAndSendMulti(address[] memory _targets, bytes[] memory _payloads, bytes32[] memory _resultMatches) external payable {
require (_targets.length == _payloads.length);
require (_targets.length == _resultMatches.length);
for (uint256 i = 0; i < _targets.length; i++) {
_check32Bytes(_targets[i], _payloads[i], _resultMatches[i]);
}
block.coinbase.transfer(msg.value);
}
function checkBytesAndSend(address _target, bytes memory _payload, bytes memory _resultMatch) external payable {
_checkBytes(_target, _payload, _resultMatch);
block.coinbase.transfer(msg.value);
}
function checkBytesAndSendMulti(address[] memory _targets, bytes[] memory _payloads, bytes[] memory _resultMatches) external payable {
require (_targets.length == _payloads.length);
require (_targets.length == _resultMatches.length);
for (uint256 i = 0; i < _targets.length; i++) {
_checkBytes(_targets[i], _payloads[i], _resultMatches[i]);
}
block.coinbase.transfer(msg.value);
}
function _check32Bytes(address _target, bytes memory _payload, bytes32 _resultMatch) internal view {
(bool _success, bytes memory _response) = _target.staticcall(_payload);
require(_success, "!success");
require(_response.length >= 32, "response less than 32 bytes");
bytes32 _responseScalar;
assembly {
_responseScalar := mload(add(_response, 0x20))
}
require(_responseScalar == _resultMatch, "response mismatch");
}
function _checkBytes(address _target, bytes memory _payload, bytes memory _resultMatch) internal view {
(bool _success, bytes memory _response) = _target.staticcall(_payload);
require(_success, "!success");
require(keccak256(_resultMatch) == keccak256(_response), "response bytes mismatch");
}
}
{
"compilationTarget": {
"FlashbotsCheckAndSend.sol": "FlashbotsCheckAndSend"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}