-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calyptus384.sol
37 lines (28 loc) · 1.33 KB
/
Calyptus384.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier:MIT
pragma solidity >= 0.8.24;
//https://x.com/CalyptusCareers/status/1796753567950250216
//As the owner of a magical vault, adventurers must pass a costly aura check to withdraw treasures 🏰
//Between the two withdraw functions in the MagicalVault smart contract, which one gets your vote and why?
contract MagicalVault {
mapping (address => uint256) public treasures;
function depositTreasures(uint256 amount) external {
treasures[msg.sender] += amount;
}
function magicalCheck(address adventurer) internal view returns (bool) {
uint256 sum = 0;
for (uint i = 0; i < treasures[adventurer]; i++) {
sum += i;
}
return sum % 2 == 0; // This is just a random condition
}
function withdraw1(uint256 amount) external {
require (amount > 0 && magicalCheck(msg.sender), "Invalid amount or failed magical check");
treasures[msg.sender] -= amount;
// logic to transfer the withdrawn treasures to the adventurer ...
}
function withdraw2(uint256 amount) external {
require (magicalCheck(msg.sender) && amount > 0 , "Invalid amount or failed magical check");
treasures[msg.sender] -= amount;
// logic to transfer the withdrawn treasures to the adventurer ...
}
}