-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.sol
More file actions
30 lines (22 loc) · 798 Bytes
/
Item.sol
File metadata and controls
30 lines (22 loc) · 798 Bytes
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
pragma solidity ^0.6.0;
import "./ItemManager.sol";
contract Item {
uint public priceInWei;
uint public paidWei;
uint public index;
ItemManager parentContract;
constructor(ItemManager _parentContract, uint _priceInWei, uint _index) public {
priceInWei = _priceInWei;
index = _index;
parentContract = _parentContract;
}
receive() external payable {
require(msg.value == priceInWei, "We don't support partial payments");
require(paidWei == 0, "Item is already paid!");
paidWei += msg.value;
(bool success, ) = address(parentContract).call{value:msg.value}(abi.encodeWithSignature("triggerPayment(uint256)", index));
require(success, "Delivery did not work");
}
fallback () external {
}
}