-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.sol
43 lines (29 loc) · 1.16 KB
/
Test.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pragma solidity ^0.6.0;
interface Oraclize{
// uint256 ETH_MAINNET = 1;
// uint256 ETH_ROPSTEN = 3;
// uint256 BSC_TESTNET = 97;
// uint256 BSC_MAINNET = 56;
function getBalance(uint256 network,address token,address user) external returns(uint256);
}
contract Test{
address public oraclizeAddress = address(0);
struct Requests {
address user;
address token;
}
mapping(address => mapping(address => uint256)) public _balanceOf;
mapping(uint256 => Requests) requestsData;
function getBalance(uint256 network,address token,address user) external returns(bool){
uint256 requsestId = Oraclize(oraclizeAddress).getBalance(network,token,user);
Requests memory _request = requestsData[requsestId];
_request.user = user;
_request.token = token;
}
function oracleCallback(uint256 requsestId,uint256 balance) external returns(bool){
require(msg.sender == oraclizeAddress,"ERR_ONLY_ORCALIAZE");
Requests memory _request = requestsData[requsestId];
_balanceOf[_request.user][_request.token] = balance;
return true;
}
}