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

Buat dapps identitas pengguna #206

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 24 additions & 0 deletions Buat smart contract di direktori contracts/Identity.sol:
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Identity {
struct User {
string name;
uint256 dob; // Date of Birth
string nationality;
bool isRegistered;
}

mapping(address => User) public users;

function register(string memory _name, uint256 _dob, string memory _nationality) public {
require(!users[msg.sender].isRegistered, "User is already registered.");
users[msg.sender] = User(_name, _dob, _nationality, true);
}

function getUser(address _user) public view returns (string memory, uint256, string memory) {
require(users[_user].isRegistered, "User not registered.");
User memory user = users[_user];
return (user.name, user.dob, user.nationality);
}
}