Created
August 8, 2022 06:02
-
-
Save smit-1923/e1c574db3721a3ed7158cdd93b8612d4 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.6.0+commit.26b70077.js&optimize=false&runs=200&gist=
This file contains 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.6.0; | |
import "hardhat/console.sol"; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
import "./BasicMetaTransaction.sol"; | |
contract newNodes is BasicMetaTransaction { | |
address payable public Owner; | |
using Counters for Counters.Counter; | |
Counters.Counter public _countTotalNode; | |
struct _Nodes{ | |
uint256 nodeId; | |
address nodeAdd; | |
uint256 diskSize; | |
string latitude; | |
string longitude; | |
string altitude; | |
string time; | |
} | |
mapping(uint256 => _Nodes) nodes; | |
constructor() public { | |
Owner = payable(msg.sender); | |
} | |
modifier onlyOwner { | |
require(msg.sender == Owner); | |
_; | |
} | |
function newNode(uint256 _nodeId, address _nodeAdd, uint256 _diskSize, string _latitude, string _longitude, string _altitude, string _time) public { | |
_countTotalNode.increment(); | |
uint countTotalNode = _countTotalNode.current(); | |
nodes[countTotalNode].nodeId = _nodeId; | |
nodes[countTotalNode].nodeAdd = _nodeAdd; | |
nodes[countTotalNode].diskSize = _diskSize; | |
geoLocation(_latitude, _longitude, _altitude); | |
time(_time); | |
} | |
function geoLocation(string _latitude, string _longitude, string _altitude) public { | |
uint countTotalNode = _countTotalNode.current(); | |
nodes[countTotalNode].latitude = _latitude; | |
nodes[countTotalNode].longitude = _longitude; | |
nodes[countTotalNode].altitude = _altitude; | |
} | |
function timeStamp(string _time) public { | |
uint countTotalNode = _countTotalNode.current(); | |
nodes[countTotalNode].time = _time; | |
} | |
function getNodeDetails(uint256 _nodeId) public view returns(address, uint256){ | |
return (nodes[_nodeId].nodeAdd, nodes[_nodeId].diskSize); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment