Fabcoin Core  0.16.2
P2P Digital Currency
token.h
Go to the documentation of this file.
1 #ifndef TOKEN_H
2 #define TOKEN_H
3 #include <string>
4 #include <vector>
5 #include <uint256.h>
6 
7 struct TokenEvent{
8  std::string address;
9  std::string sender;
10  std::string receiver;
12  uint64_t blockNumber;
15 
17  {
18  SetNull();
19  }
20 
21  void SetNull()
22  {
23  blockHash.SetNull();
24  blockNumber = 0;
25  transactionHash.SetNull();
26  value.SetNull();
27  }
28 };
29 
30 struct TokenData;
31 
32 class Token
33 {
34 public:
35  Token();
36  ~Token();
37 
38  // Set command data
39  void setAddress(const std::string &address);
40  void setDataHex(const std::string &datahex);
41  void setAmount(const std::string &amount);
42  void setGasLimit(const std::string &gaslimit);
43  void setGasPrice(const std::string &gasPrice);
44  void setSender(const std::string &sender);
45  void clear();
46 
47  // Get transaction data
48  std::string getTxId();
49 
50  // ABI Functions
51  bool name(std::string& result, bool sendTo = false);
52  bool approve(const std::string& _spender, const std::string& _value, bool& success, bool sendTo = false);
53  bool totalSupply(std::string& result, bool sendTo = false);
54  bool transferFrom(const std::string& _from, const std::string& _to, const std::string& _value, bool& success, bool sendTo = false);
55  bool decimals(std::string& result, bool sendTo = false);
56  bool burn(const std::string& _value, bool& success, bool sendTo = false);
57  bool balanceOf(std::string& result, bool sendTo = false);
58  bool balanceOf(const std::string& spender, std::string& result, bool sendTo = false);
59  bool burnFrom(const std::string& _from, const std::string& _value, bool& success, bool sendTo = false);
60  bool symbol(std::string& result, bool sendTo = false);
61  bool transfer(const std::string& _to, const std::string& _value, bool sendTo = false);
62  bool approveAndCall(const std::string& _spender, const std::string& _value, const std::string& _extraData, bool& success, bool sendTo = false);
63  bool allowance(const std::string& _from, const std::string& _to, std::string& result, bool sendTo = false);
64 
65  // ABI Events
66  bool transferEvents(std::vector<TokenEvent>& tokenEvents, int64_t fromBlock = 0, int64_t toBlock = -1);
67  bool burnEvents(std::vector<TokenEvent>& tokenEvents, int64_t fromBlock = 0, int64_t toBlock = -1);
68 
69 private:
70  bool exec(const std::vector<std::string>& input, int func, std::vector<std::string>& output, bool sendTo);
71  bool execEvents(int64_t fromBlock, int64_t toBlock, int func, std::vector<TokenEvent> &tokenEvents);
72 
73  Token(Token const&);
74  Token& operator=(Token const&);
75 
76 private:
78 };
79 
80 #endif // TOKEN_H
void SetNull()
Definition: uint256.h:46
TokenData * d
Definition: token.h:77
uint64_t blockNumber
Definition: token.h:12
Definition: token.h:32
uint256 value
Definition: token.h:14
std::string address
Definition: token.h:8
const char * name
Definition: rest.cpp:36
void SetNull()
Definition: token.h:21
256-bit opaque blob.
Definition: uint256.h:132
TokenEvent()
Definition: token.h:16
uint256 transactionHash
Definition: token.h:13
std::string receiver
Definition: token.h:10
uint256 blockHash
Definition: token.h:11
std::string sender
Definition: token.h:9