Created
January 26, 2023 17:29
-
-
Save ArslanKathia/3568e29a0cf026d3b0ec3024c0e11555 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8; | |
struct donate_dts{ | |
string name; | |
uint age; | |
string location; | |
uint donation; | |
} | |
contract advMapping{ | |
mapping(uint => string) public emp_id; | |
function setIds() public { | |
emp_id[10] = "Arslan"; | |
emp_id[20] = "Ahmad"; | |
emp_id[14] = "Raza"; | |
} | |
function getId(uint _id) public view returns(string memory){ | |
return emp_id[_id]; | |
} | |
//advance mapping on key and struct value | |
mapping(address => donate_dts) ngo_acc; | |
function setDonation(string memory _name,uint _age,string memory _location,uint _donate) public{ | |
// donate_dts memory dts; | |
//dts.name = _name; | |
//dts.age = _age; | |
//dts.location = _location; | |
//dts.donation = ngo_acc[msg.sender].donation + _donate; | |
ngo_acc[msg.sender] = donate_dts(_name,_age,_location,ngo_acc[msg.sender].donation + _donate); | |
} | |
function getDonationDetails(address _addr)public view returns(donate_dts memory){ | |
return ngo_acc[_addr]; | |
} | |
function deleteRecord(address _addr) public{ | |
delete ngo_acc[_addr]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment