Skip to content

Instantly share code, notes, and snippets.

@padunk
Created July 25, 2021 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save padunk/54faf3c798c7e85beaf8fc441c3c00e7 to your computer and use it in GitHub Desktop.
Save padunk/54faf3c798c7e85beaf8fc441c3c00e7 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.12+commit.27d51765.js&optimize=false&runs=200&gist=
pragma solidity ^0.6.7;
contract MyFirstContract {
uint256 number = 0;
string[] names;
mapping(string => uint) public phoneNumbers;
function addPhoneNumber(string memory _name, uint _number) public {
phoneNumbers[_name] = _number;
}
function getPhoneNumber(string memory _name) public view returns(uint) {
return phoneNumbers[_name];
}
function addName(string memory _name) public {
names.push(_name);
}
function getName(uint _index) public view returns(string memory) {
return names[_index];
}
function changeNumber (uint256 _number) public {
number = number + _number;
}
function getNumber() public view returns(uint256) {
return number;
}
function getNumberMultiplied(uint _num) public view returns(uint) {
return number * _num;
}
function addNumbers(uint _num1, uint _num2) public {
number = _num1 + _num2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment