-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_transact_frontend.html
More file actions
55 lines (48 loc) · 1.73 KB
/
Example_transact_frontend.html
File metadata and controls
55 lines (48 loc) · 1.73 KB
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
<html>
<head>
<title>Transact example</title>
<a href="index.html">Back to Contents</a>
<script type="text/javascript">
//irrelevant as this is just an example of transact function - could be sent to anyone.
var address = "0x362f32678116879bd2a62efc543a8b41d02d2f28";
// describes the contract as having a single function with two input parameters, both unsigned integers 256
var desc = [{
"name": "Send",
"inputs": [
{
"name": "to",
"type": "uint256"
},
{
"name": "value",
"type": "uint256"
}
]
}];
//Builds the contract using our desc and nonsense address.
var contract = web3.contract(address, desc);
//function to send transaction using parameters from the HTML input boxes
function createTransaction() {
receiverAddress = document.querySelector('#receiverAddress').value;
console.log(receiverAddress);
amount = document.querySelector('#amount').value;
console.log(amount);
contract.Send(receiverAddress, amount).transact()
}
</script>
</head>
<body>
<div>
<h3>Transact Example</h3>
</div>
<div>
<input id="receiverAddress" class="form-control" type="text" placeholder="Receiver address"></input><br>
<input id="amount" class="form-control" type="text" placeholder="Amount"></input><br>
</div>
<button onclick="createTransaction();">Send transaction</button>
</div>
<div>
Typical transaction for a coin contract. If you put a value in either of the input boxes larger than 0x1fffffffffffff it will start to round down the values passed to it from the input boxes (try sending an address for example).
</div>
</body>
</html>