Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract updated #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/contracts/DTube.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pragma solidity ^0.5.0;
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract DTube {
uint public videoCount = 0;
string public name = "DTube";

error NotProperHash();
error NotProperTitle();

uint256 public videoCount;
string public constant name = "DTube";
mapping(uint => Video) public videos;

struct Video {
Expand All @@ -19,16 +25,16 @@ contract DTube {
address author
);

constructor() public {
}

function uploadVideo(string memory _videoHash, string memory _title) public {
function uploadVideo(string calldata _videoHash, string calldata _title) public {
// Make sure the video hash exists
require(bytes(_videoHash).length > 0);
if(bytes(_videoHash).length == 0){
revert NotProperHash();
}

// Make sure video title exists
require(bytes(_title).length > 0);
// Make sure uploader address exists
require(msg.sender!=address(0));
if(bytes(_title).length == 0){
revert NotProperTitle();
}

// Increment video id
videoCount ++;
Expand Down