Skip to content

Instantly share code, notes, and snippets.

@samanshahmohamadi
Created March 12, 2019 15:13
Show Gist options
  • Save samanshahmohamadi/76b2ab8af6c865bc7c64bfdec3d4f42c to your computer and use it in GitHub Desktop.
Save samanshahmohamadi/76b2ab8af6c865bc7c64bfdec3d4f42c 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.4.25+commit.59dbf8f1.js&optimize=false&gist=
pragma solidity ^0.4.25;
contract AccountAddrResolverI {
address public addr;
address owner;
function AccountAddrResolverI(){
owner = msg.sender;
}
function changeOwner(address newowner){
if (msg.sender != owner) throw;
owner = newowner;
}
function getAddress() returns (address oaddr){
return addr;
}
function setAddr(address newaddr){
if (msg.sender != owner) throw;
addr = newaddr;
}
}
pragma solidity ^0.4.25;
import "./usingAccount.sol";
contract App is usingAccount {
uint public DieselPriceUSD;
function App() {
// OAR = AccountAddrResolverI(0x920cd3f7ed02c5d61e2556308d53a4d9d1e58bf2);
}
function update(uint amount) payable {
add(amount);
}
function getBalance(uint amount) public view returns (uint) {
return get();
}
}
pragma solidity 0.4.25;
contract AccountI {
address public cbAddress;
function add(uint _amount) public returns (uint);
function deduct(uint _amount) public returns (uint);
function get() public view returns (uint);
}
contract AccountAddrResolverI {
function getAddress() public returns (address _addr);
}
contract usingAccount {
AccountAddrResolverI OAR;
AccountI account;
event LogAddress(address str);
modifier accountAPI {
OAR = AccountAddrResolverI(0x4a75E1bcB8a19Cf1bEe802BFA0F81df25Aa1510b);
emit LogAddress(OAR.getAddress());
if(address(account) != OAR.getAddress())
account = AccountI(OAR.getAddress());
_;
}
function add(uint _amount) public accountAPI returns (uint) {
return account.add(_amount);
}
function deduct(uint _amount) public accountAPI returns (uint) {
return account.deduct(_amount);
}
function get() public accountAPI returns (uint) {
return 10;
}
function account_cbAddress() accountAPI internal returns (address){
return account.cbAddress();
}
/* function __callback(bytes32 myid, string result) public {
__callback(myid, result, new bytes(0));
}
function __callback(bytes32 myid, string result, bytes proof) public {
return;
// Following should never be reached with a preceding return, however
// this is just a placeholder function, ideally meant to be defined in
// child contract when proofs are used
myid; result; proof; // Silence compiler warnings
oraclize = OraclizeI(0); // Additional compiler silence about making function pure/view.
}*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment