Skip to content

Instantly share code, notes, and snippets.

Created February 9, 2017 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/c23f944b139a76693abbae261ad577b8 to your computer and use it in GitHub Desktop.
Save anonymous/c23f944b139a76693abbae261ad577b8 to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.9+commit.364da425.js&optimize=undefined&gist=
/*
Data Master that calls Data Storage Smart Contract
Developed by:
MarketPay.io , 2017
http://lnked.in/blockchain
*/
pragma solidity ^0.4.6;
/// ---- dataStorage interface
contract dataStorage {
function getBalanceOf(address _account) constant returns (uint256 balance);
function setBalanceOf(address _account, uint256 _value);
}
contract mortal {
address owner;
function mortal() { owner = msg.sender; }
function kill() { if (msg.sender == owner) suicide(owner); }
}
contract dataMaster is mortal {
/// ---- Data
address dataStorageAddr = 0x2bdaa67309293f99644dff29fbc2bb53915d069e;
// dataStorage instantation
dataStorage myDataStorage = dataStorage(dataStorageAddr);
/// ---- Events
event Test(string _test, address _account, uint256 _value);
/// ---- Methods
/// @notice Perform test, just querying balances
function testRead(address _account) {
uint256 _value;
_value = myDataStorage.getBalanceOf(_account);
Test("Reading balance of account", _account, _value);
}
/// @notice Perform test, just updating balances
function testWrite(address _account, uint256 _value) {
myDataStorage.setBalanceOf(_account, _value);
Test("Setting balance of account", _account, _value);
}
/// @notice Perform some simple tests, wirting a balance and querying it later
function test() {
testRead(0x0);
testRead(0x1);
testWrite(0x0, 99);
testWrite(0x1, 101);
testRead(0x0);
testRead(0x1);
}
/// @notice This unnamed function (fallback) is called whenever someone tries to send ether to it
function () {
throw; // Prevents accidental sending of ether
}
}
/*
Data Storage callable Smart Contract
Developed by:
MarketPay.io , 2017
http://lnked.in/blockchain
*/
pragma solidity ^0.4.6;
contract mortal {
address owner;
function mortal() { owner = msg.sender; }
function kill() { if (msg.sender == owner) suicide(owner); }
}
contract dataStorage is mortal {
/// ---- Data
/// @notice Key-value to account for token balance of Ethereum accounts
mapping (address => uint256) private balanceOf;
/// ---- Events
event SetBalanceOf(address _from, address _account, uint256 _value);
/// ---- Methods
/// @notice Read an account balance
/// @param _account whose balance...
/// @return the account balance
function getBalanceOf(address _account) constant returns (uint256 balance) {
return balanceOf[_account];
}
/// @notice Modify an account balance
/// @param _account whose balance...
/// @param _value how much...
function setBalanceOf(address _account, uint256 _value) {
balanceOf[_account] = _value;
SetBalanceOf(msg.sender, _account, _value);
}
/// @notice This unnamed function (fallback) is called whenever someone tries to send ether to it
function () {
throw; // Prevents accidental sending of ether
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment