Address Contract Verified
Address
0x20A0d13C4643AB962C6804BC6ba6Eea0505F11De
Balance
0 ETH
Nonce
1
Code Size
2397 bytes
Creator
0x46C604b1...A76b at tx 0x2007858a...fac795
Indexed Transactions
0
Contract Bytecode
2397 bytes
0x60806040526004361061004d575f3560e01c806301ffc9a7146101ac578063150b7a02146101e0578063bc197c8114610223578063da3ef9d21461024e578063f23a6e61146102625761010e565b3661010e577f00000000000000000000000000000000000000000000000000000000000052085a101561007c57005b5f7f000000000000000000000000bc0f3b23930fff9f4894914bd745ababa95882656001600160a01b0316346040515f6040518083038185875af1925050503d805f81146100e5576040519150601f19603f3d011682016040523d82523d5f602084013e6100ea565b606091505b505090508061010c57604051632deea62960e21b815260040160405180910390fd5b005b336001600160a01b037f000000000000000000000000bc0f3b23930fff9f4894914bd745ababa9588265161461015757604051631924434360e21b815260040160405180910390fd5b5f61016061028d565b905061010c5f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525050506001600160a01b0384169190503461029d565b3480156101b7575f80fd5b506101cb6101c636600461058e565b61033d565b60405190151581526020015b60405180910390f35b3480156101eb575f80fd5b5061020a6101fa366004610681565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020016101d7565b34801561022e575f80fd5b5061020a61023d366004610762565b63bc197c8160e01b95945050505050565b348015610259575f80fd5b5061010c610373565b34801561026d575f80fd5b5061020a61027c366004610805565b63f23a6e6160e01b95945050505050565b5f6102985f3661044f565b905090565b6060814710156102c75760405163cd78605960e01b81523060048201526024015b60405180910390fd5b5f80856001600160a01b031684866040516102e29190610865565b5f6040518083038185875af1925050503d805f811461031c576040519150601f19603f3d011682016040523d82523d5f602084013e610321565b606091505b5091509150610331868383610509565b925050505b9392505050565b5f6001600160e01b03198216630271189760e51b148061036d57506301ffc9a760e01b6001600160e01b03198316145b92915050565b336001600160a01b037f000000000000000000000000bc0f3b23930fff9f4894914bd745ababa958826516146103bc57604051631924434360e21b815260040160405180910390fd5b5f7f000000000000000000000000bc0f3b23930fff9f4894914bd745ababa95882656001600160a01b0316476040515f6040518083038185875af1925050503d805f8114610425576040519150601f19603f3d011682016040523d82523d5f602084013e61042a565b606091505b505090508061044c57604051632deea62960e21b815260040160405180910390fd5b50565b5f8160448110610502575f8484610467602085610891565b6104729282906108b0565b61047b916108d7565b60408051808201909152600f81526e111c9bdb99531a588b9d185c99d95d608a1b60209091015290507fc1b9dfe6c6d6343c26291b77edfcc5dbc62c3afa2ee72581da4e3cdbe96a0a4f81016105005784846104d8603485610891565b906104e4602086610891565b926104f1939291906108b0565b6104fa916108f4565b60601c92505b505b5092915050565b60608261051e5761051982610565565b610336565b815115801561053557506001600160a01b0384163b155b1561055e57604051639996b31560e01b81526001600160a01b03851660048201526024016102be565b5080610336565b8051156105755780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f6020828403121561059e575f80fd5b81356001600160e01b031981168114610336575f80fd5b80356001600160a01b03811681146105cb575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561060d5761060d6105d0565b604052919050565b5f82601f830112610624575f80fd5b813567ffffffffffffffff81111561063e5761063e6105d0565b610651601f8201601f19166020016105e4565b818152846020838601011115610665575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215610694575f80fd5b61069d856105b5565b93506106ab602086016105b5565b925060408501359150606085013567ffffffffffffffff8111156106cd575f80fd5b6106d987828801610615565b91505092959194509250565b5f82601f8301126106f4575f80fd5b8135602067ffffffffffffffff821115610710576107106105d0565b8160051b61071f8282016105e4565b9283528481018201928281019087851115610738575f80fd5b83870192505b848310156107575782358252918301919083019061073e565b979650505050505050565b5f805f805f60a08688031215610776575f80fd5b61077f866105b5565b945061078d602087016105b5565b9350604086013567ffffffffffffffff808211156107a9575f80fd5b6107b589838a016106e5565b945060608801359150808211156107ca575f80fd5b6107d689838a016106e5565b935060808801359150808211156107eb575f80fd5b506107f888828901610615565b9150509295509295909350565b5f805f805f60a08688031215610819575f80fd5b610822866105b5565b9450610830602087016105b5565b93506040860135925060608601359150608086013567ffffffffffffffff811115610859575f80fd5b6107f888828901610615565b5f82515f5b81811015610884576020818601810151858301520161086a565b505f920191825250919050565b8181038181111561036d57634e487b7160e01b5f52601160045260245ffd5b5f80858511156108be575f80fd5b838611156108ca575f80fd5b5050820193919092039150565b8035602083101561036d575f19602084900360031b1b1692915050565b6bffffffffffffffffffffffff1981358181169160148510156105005760149490940360031b84901b169092169291505056fea264697066735822122021709d5ddbd7214c74af6fd5cf48c3441f72db1cd65b94dbc90f4008deb683cf64736f6c63430008150033
Verified Source Code Full Match
Compiler: v0.8.21+commit.d9974bed
EVM: shanghai
Optimization: Yes (200 runs)
BoringDrone.sol 124 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.21;
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {ERC721Holder} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import {DroneLib} from "src/base/Drones/DroneLib.sol";
// .
// ......
// ..........
// ..:::.......
// ..::........
// ....::::.......
// ......::..:....
// ........:..:...
// ............ .......:.:........
// ..:::......... ..........:..::...
// ....::::..::..... ..........:...::..
// ....-:::...::.... ...............:-...
// .....--::::.::................:...:...
// ...:-::::::::..............:..:::.
// .....--:::::-:.............:::::....
// ....:==-:::--............::..-...
// .....:*+-:::::..........::.:-..
// ......:+*=---:.......:::::::......
// ........::::--+#*==:....:-------::........
// .....-=---=+-=+--===##==:..-+++++=====---:....
// ....=*##*====-+*=++=-===+#+=-=*+**+*******+==:......
// .....==:=####*=----*+==+=====::=#*++*******##*****=-:.......
// ......:##+-++=+++=---+####*+==--:--=+#%#*###**********==++=-.....
// ....-:+%*=---===++==+*%%%###++=-----+*#@%###@%%###****#*#%%**+=:..
// ..:*=-===----+*###**++%###%%#*+=+====+++**#@@%%%##**#%%#%@%###*-....
// ..+#=--++*+++*#%%%##***#%%%%%%#*+++==+***+++=+%%###%%%%%%%%@%##=.::.
// ..-=#+==+#%%#***#++##%######%##%@%#*++##*+**+*##%%#%##%##+##@@%*+:=+:.
// ..=+-*%%#*+#%%*+=%@#+*%@%%%%%%###%#*===*********##%%%*#*#@@%@%%*=-==::..
// ..*%#++####***+#@@%===-=+#%@%*+++##+=-==+*******#%@%*=##%@@@@%%**+=-+:..
// ..=###*++**+=+%@@@#--::.....::-*#=++=---==++++*#%%#+=-**@@@@@%**#-....
// ...-**++++===+@%%%%=...........+#*+##=::::::-=+%*---::-=+#@@@%#+##-....
// ....::::::---@@@%#*:... ...-#@#:........:=%@#:.....::=+*###**##:.
// ..........=+%@%=.. ...*%%*.........:#@%-....=-:::-=+***#+-...
// ...#@%%%#:.. ..:%@@=.. ...+%%... ...==---+*##*=...
// ...#@@@@@%:. ..:#@%:.. ..=*#-... ..........-#**...
// ..*@@@@@%-... ..:*#+.... ..=*@%.. ....=+..
// ..:%@%%%#:... ..-@@%:... ..+@@+. ....
// .....-*%%*... ..=@@%-... ...=%#:.
// ....:*#:..... ..-@%%-.. ..:%=...
// ..:+++-....... ...+*#:.. ....**:.
// ..-:...... ....==.......=*:..
// .... ...-#:. ....-+:...
// .... ..:=:.. ..:*=....
// ....... .:=-...
// ... .......
//
//
contract BoringDrone is ERC721Holder, ERC1155Holder {
using Address for address;
//============================== MODIFIERS ===============================
modifier onlyBoringVault() {
if (msg.sender != boringVault) revert BoringDrone__OnlyBoringVault();
_;
}
//============================== ERRORS ===============================
error BoringDrone__OnlyBoringVault();
error BoringDrone__ReceiveFailed();
//============================== CONSTRUCTOR ===============================
/**
* @notice The address of the BoringVault that can control this drone.
*/
address internal immutable boringVault;
/**
* @notice The amount of gas needed to forward native to the BoringVault.
* @dev This value was determined from guess and check. Realisitically, the value should be closer to 10k, but
* 21k is used for extra safety.
*/
uint256 internal immutable safeGasToForwardNative;
constructor(address _boringVault, uint256 _safeGasToForwardNative) {
boringVault = _boringVault;
safeGasToForwardNative = _safeGasToForwardNative < 21_000 ? 21_000 : _safeGasToForwardNative;
}
//============================== WITHDRAW ===============================
/**
* @notice Withdraws all native from the drone.
*/
function withdrawNativeFromDrone() external onlyBoringVault {
(bool success,) = boringVault.call{value: address(this).balance}("");
if (!success) revert BoringDrone__ReceiveFailed();
}
//============================== FALLBACK ===============================
/**
* @notice This contract in its current state can only be interacted with by the BoringVault.
* @notice The real target is extracted from the call data using `extractTargetFromCalldata()`.
* @notice The drone then forwards
*/
fallback() external payable onlyBoringVault {
// Extract real target from end of calldata
address target = DroneLib.extractTargetFromCalldata();
// Forward call to real target.
target.functionCallWithValue(msg.data, msg.value);
}
//============================== RECEIVE ===============================
receive() external payable {
// If gas left is less than safe gas needed to forward native, return.
if (gasleft() < safeGasToForwardNative) return;
(bool success,) = boringVault.call{value: msg.value}("");
if (!success) revert BoringDrone__ReceiveFailed();
}
}
Address.sol 159 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
ERC721Holder.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)
pragma solidity ^0.8.20;
import {IERC721Receiver} from "../IERC721Receiver.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or
* {IERC721-setApprovalForAll}.
*/
abstract contract ERC721Holder is IERC721Receiver {
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {
return this.onERC721Received.selector;
}
}
ERC1155Holder.sol 42 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/utils/ERC1155Holder.sol)
pragma solidity ^0.8.20;
import {IERC165, ERC165} from "../../../utils/introspection/ERC165.sol";
import {IERC1155Receiver} from "../IERC1155Receiver.sol";
/**
* @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
*
* IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
* stuck.
*/
abstract contract ERC1155Holder is ERC165, IERC1155Receiver {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}
DroneLib.sol 25 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;
library DroneLib {
bytes32 internal constant TARGET_FLAG = keccak256(bytes("DroneLib.target"));
function extractTargetFromCalldata() internal pure returns (address target) {
target = extractTargetFromInput(msg.data);
}
function extractTargetFromInput(bytes calldata data) internal pure returns (address target) {
// Look at the last 32 bytes of calldata and see if the TARGET_FLAG is there.
uint256 length = data.length;
if (length >= 68) {
bytes32 flag = bytes32(data[length - 32:]);
if (flag == TARGET_FLAG) {
// If the flag is there, extract the target from the calldata.
target = address(bytes20(data[length - 52:length - 32]));
}
}
// else no target present, so target is address(0).
}
}
IERC721Receiver.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC1155Receiver.sol 59 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Interface that must be implemented by smart contracts in order to receive
* ERC-1155 token transfers.
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Read Contract
supportsInterface 0x01ffc9a7 → bool
Write Contract 4 functions
These functions modify contract state and require a wallet transaction to execute.
onERC1155BatchReceived 0xbc197c81
address
address
uint256[]
uint256[]
bytes
returns: bytes4
onERC1155Received 0xf23a6e61
address
address
uint256
uint256
bytes
returns: bytes4
onERC721Received 0x150b7a02
address
address
uint256
bytes
returns: bytes4
withdrawNativeFromDrone 0xda3ef9d2
No parameters
Token Balances (3)
View Transfers →Recent Transactions
No transactions found for this address