Skip to content

Instantly share code, notes, and snippets.

@samanshahmohamadi
Created March 12, 2019 14:57
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 samanshahmohamadi/375d14a361d3366695fdd7e67c8cd777 to your computer and use it in GitHub Desktop.
Save samanshahmohamadi/375d14a361d3366695fdd7e67c8cd777 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);
}
}
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