-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbitcoincomp.cpp
36 lines (32 loc) · 1.2 KB
/
bitcoincomp.cpp
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
#include "provable/eos_api.hpp"
class bitcoincomp : public eosio::contract
{
public:
using contract::contract;
bitcoincomp(eosio::name receiver, eosio::name code, datastream<const char*> ds) : contract(receiver, code, ds) {}
[[eosio::action]]
void compute()
{
// Prepare computation arguments: IPFS Multihash and Bitcoin Address
std::string bitcoinAddress = "3D2oetdNuZUqQHPJmcMDDHYoqkyNVsFk9r";
std::vector<std::vector<unsigned char>> args = {
string_to_vector("QmYe37uvAUvZZ8ksV726BZt6dJFWP764sTPisNQtuDZVom"),
string_to_vector(bitcoinAddress)
};
std::vector<unsigned char> query = provable_set_computation_args(args);
print("Sending query to Provable...");
provable_query("computation", query);
}
[[eosio::action]]
void callback(
const eosio::checksum256 queryId,
const std::vector<unsigned char> result,
const std::vector<unsigned char> proof
)
{
require_auth(provable_cbAddress());
// Print the account balance of the Bitcoin account
const std::string result_str = vector_to_string(result);
print("Account balance:", result_str);
}
};