Personality Test

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

pragma solidity >=0.4.21 <0.6.

0;

contract GameTransaction {
address public owner; //
struct GSe {
address addr;
string gameid;
uint8 gamestate;
string comment;
//uint32 timestamp;
}

struct GSs { // create a temporary storage for the user in datachain


address addr; // sender address
string assetname;
string assethash;
uint8 assetstate;
string gamecomment; // user with right permission
//uint32 gametimestamp; // time of transaction
}

mapping (address => GSe) start_tranc;// using unique identifier address to


access record for Datachain
mapping (address => GSs) start_service; //using unique identifier address to
access record for user

constructor () public{
owner = msg.sender;
}

//Events
// create a storage that will triggered an event at the Player side
event Check_Validity (address addr, string game_store_Id,uint8
game_Id_Validity,string comment);//uint32 timeStamp);
event Check_Asset_Validity (address addr,string assetname,string assethash,
uint8 game_state_Validity,string gamecomment);

// save all user records in datachain or behaviorchain based on permission


level
function Check_ValidityofGame_Store(address addr,string memory game_store_Id,
uint8 game_Id_Validity, string memory comment) public payable {
start_tranc[addr].addr = addr; // assigned the Datachain with the input
data
start_tranc[addr].gameid = game_store_Id;
start_tranc[addr].gamestate = game_Id_Validity;
start_tranc[addr].comment = comment;
//start_tranc[addr].timestamp = timeStamp;
emit Check_Validity(msg.sender, start_tranc[addr].gameid,
start_tranc[addr].gamestate, start_tranc[addr].comment); // store all record in
Datachain
}

// store record of user in behaviorchain


function Check_ValidityofGame_Service(address addr,string memory
assetname,string memory assethash,uint8 game_state_Validity, string memory
gamecomment) public payable {
start_service[addr].addr = addr; // assigned the Datachain with the input
data
start_service[addr].assetname = assetname;
start_service[addr].assethash = assethash;
start_service[addr].assetstate = game_state_Validity;
start_service[addr].gamecomment = gamecomment;
// start_service[addr].gametimestamp = timestamp;
emit
Check_Asset_Validity(msg.sender,start_service[addr].assetname,start_service[addr].a
ssethash,start_service[addr].assetstate,start_service[addr].gamecomment);//,start_s
ervice[addr].gametimestamp); // store all input data into behavior chain
}
bool Game_service_requested;
string s_name;
//function Player_Request(string service) public () {
// s_name = service;

//}
string service_codes;
string MAC_address;

bytes32 assethash;
bytes32 hashvalue;
function Player_Hash_Conversion() public payable returns (string memory,string
memory) {
//require(service_codes,MAC_address);
//return keccak256(service_codes + MAC_address);
}
//function smartcontractoracle(string name) {
// require (service_codes,assethash,MAC_address);
// hashvalue = assethash;
//}
//function smartcontractmaintainer(string name) {
// require(service_codes,MAC_address);

//}
// Retrieve all records from the storage based on user address
function Check_ValidityofPlayer(address addr) public view returns(string
memory,uint8 ,string memory) {
//GSe memory temp = start_tranc[addr];
if (start_tranc[addr].addr == addr) {

return(start_tranc[addr].gameid,start_tranc[addr].gamestate,start_tranc[addr].comme
nt);
}
}
// Retrieve all records from the storage based on user address
function Check_ValidityofGame(address addr) public view returns(string
memory,uint8) {
//GSs memory temp2 = start_service[addr];
if (start_service[addr].addr == addr) {
return(start_service[addr].assetname,start_service[addr].assetstate);
}
}

//Compare the two password hashes if it not modified


function compareHashValue(bytes memory a, bytes memory b) internal pure returns
(bool equal) {
if (a.length != b.length) {
return false;
} else {// keccak256 cryptographic hash function for ethereum
return keccak256(abi.encodePacked(a)) ==
keccak256(abi.encodePacked(b)); // compare two hashes
}
}

You might also like