Skip to content

Instantly share code, notes, and snippets.

@agatsoh
Created October 28, 2016 12:20
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 agatsoh/9f6a57b735c679b392e306edc2f7ab77 to your computer and use it in GitHub Desktop.
Save agatsoh/9f6a57b735c679b392e306edc2f7ab77 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.2;
contract Account{
int public variableAB;
int public variableBA;
int public balanceAB;
function Account(int variableAB, int variableBA){
variableAB = variableAB;
variableBA = variableBA;
}
function setLines(int variableAB, int variableBA){
variableAB = variableAB;
variableBA = variableBA;
}
function setBalance(int balanceAB){
balanceAB = balanceAB;
}
}
contract TLTokenMap{
mapping(bytes32 => Account) accounts;
function approve(bytes32 name, int variableAB, int variableBA){
Account account = accounts[name];
if(address(account) == address(0)){
address newAccount = new Account(variableAB, variableBA);
accounts[name] = Account(newAccount);
}else{
account.setLines(variableAB, variableBA);
}
}
function generateBalance(bytes32 name, int balanceAB){
Account account = accounts[name];
if(address(account) == address(0)){
return;
}else{
account.setBalance(balanceAB);
}
}
function getAccount(bytes32 name) constant returns (int, int, int){
Account account = accounts[name];
if(address(account) == address(0)){
return (0, 0, 0);
}else{
return (account.variableAB(), account.variableBA(), account.balanceAB());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment