-
Notifications
You must be signed in to change notification settings - Fork 0
/
WEB3_Kaleido.html
60 lines (50 loc) · 2.39 KB
/
WEB3_Kaleido.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
<!DOCTYPE html>
<html>
<head>
<title>Web3.js e Kaleido</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
</head>
<body>
<h1>Interagindo com um Contrato Inteligente usando Web3 e Kaleido</h1>
<input id="valueInput" type="number" placeholder="Enter value">
<button onclick="setValue()">Set Value</button>
<button onclick="getValue()">Get Value</button>
<h2 id="valueOutput"></h2>
<script>
/* Altere com as informações de sua conta no Kaleido - Change with informations of your account in Kaleido */
async function setValue() {
const value = document.getElementById('valueInput').value;
const url = `https://u0bpn6bhay-u0zldmm6dj-connect.us0-aws.kaleido.io/gateways/u0sepayx8n/0x869064f9d01deaf57126fba62aeaaa231588c2e3/setValue?newValue=${value}&kld-from=0xfca87376bac0ee8462ead81a87c03ec3e0c2fdd0`;
const headers = {
'Authorization': 'Basic dTBxcGJiYXVkYjoxSjg0WlNSaUJBS192UHMxT3ZKZF9EcF9ROFJkN0RBczgxci1KU291dUFF',
'Content-Type': 'application/json'
};
try {
const response = await axios.post(url, {}, {
headers
});
console.log(response);
} catch (error) {
console.error(`Erro ao definir o valor: ${error}`);
}
}
/* Altere com as informações de sua conta no Kaleido - Change with informations of your account in Kaleido */
async function getValue() {
const url = 'https://u0bpn6bhay-u0zldmm6dj-connect.us0-aws.kaleido.io/gateways/u0sepayx8n/0x869064f9d01deaf57126fba62aeaaa231588c2e3/getValue?kld-from=0xfca87376bac0ee8462ead81a87c03ec3e0c2fdd0' ;
const headers = {
'Authorization': 'Basic dTBxcGJiYXVkYjoxSjg0WlNSaUJBS192UHMxT3ZKZF9EcF9ROFJkN0RBczgxci1KU291dUFF',
'Content-Type': 'application/json'
};
try {
const response = await axios.get(url, {
headers
});
document.getElementById('valueOutput').textContent = `O valor atual é: ${response.data.output}`;
console.log(response);
} catch (error) {
console.error(`Erro ao obter o valor: ${error}`);
}
}
</script>
</body>
</html>