forked from pi-apps/PiOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDecentralized Storage(IPFS)
36 lines (27 loc) · 1.06 KB
/
Decentralized Storage(IPFS)
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ContentPlatform {
// Token untuk membayar pembuat konten
mapping(address => uint256) public balances;
struct Content {
address creator;
string ipfsHash; // hash dari konten di IPFS
uint256 reward;
}
Content[] public contents;
event ContentCreated(address indexed creator, string ipfsHash, uint256 reward);
function createContent(string memory ipfsHash) public {
uint256 reward = 100; // imbalan tetap untuk setiap konten yang diunggah
contents.push(Content(msg.sender, ipfsHash, reward));
balances[msg.sender] += reward;
emit ContentCreated(msg.sender, ipfsHash, reward);
}
function withdrawReward() public {
uint256 amount = balances[msg.sender];
require(amount > 0, "No reward to withdraw");
balances[msg.sender] = 0;
payable(msg.sender).transfer(amount);
}
// Fungsi fallback untuk menerima dana
receive() external payable {}
}