-
Notifications
You must be signed in to change notification settings - Fork 0
/
firstExample.html
75 lines (65 loc) · 1.51 KB
/
firstExample.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
<head>
<script src="https://www.moneybutton.com/moneybutton.js"></script>
<script type="text/javascript" src="https://unpkg.com/bsv@0.21.5/bsv.min.js"></script>
<style>
body {
padding: 50px;
font-family: arial;
font-size: 12px;
}
div {
width: 500px;
margin: 0 auto;
padding: 10px 0;
}
</style>
<script>
var query = {
"v": 3,
"q": {
"find": {"out.b1":"Yml0am91cm5hbA=="},
"limit": 20
}
}
// Turn the query into base64 encoded string.
// This is required for accessing a public bitdb node
var b64 = btoa(JSON.stringify(query));
var url = "https://genesis.bitdb.network/q/1FnauZ9aUH2Bex6JzdcV4eNX7oLSSEbxtN/" + b64;
// Attach API KEY as header
var header = {
headers: { key: "1KJPjd3p8khnWZTkjhDYnywLB2yE1w5BmU" }
};
// Make an HTTP request to bitdb.network public endpoint
fetch(url, header).then(function(r) {
console.log(r.json);
return r.json()
}).then(function(r) {
let res = r.u.concat(r.c)
console.log(r)
// "r.c" stands for confirmed transactions response array
// Parse the response and render the results on the screen
r.c.forEach(function(output) {
var div = document.createElement("div");
div.innerHTML = output.blk.h;
document.body.appendChild(div)
})
})
</script>
</head>
<body>
<div id="my-money-button"></div>
></div>
</body>
<script>
const div = document.getElementById('my-money-button')
moneyButton.render(div, {
outputs: [{
type: 'SCRIPT',
script: hex,
amount: '0.05',
currency: 'USD'
}]
})
</script>
</html>