-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
95 lines (92 loc) · 2.29 KB
/
main.js
File metadata and controls
95 lines (92 loc) · 2.29 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
window.addEventListener("load", function() {
// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof web3 !== "undefined") {
// Use Mist/MetaMask's provider
web3js = new Web3(web3.currentProvider);
} else {
// Handle the case where the user doesn't have web3. Probably
// show them a message telling them to install Metamask in
// order to use our app.
}
// Now you can start your app & access web3js freely:
});
var escrowContractABI = [
{
constant: false,
inputs: [],
name: "release",
outputs: [],
payable: false,
stateMutability: "nonpayable",
type: "function"
},
{
constant: true,
inputs: [],
name: "getSellerAndBuyerDetails",
outputs: [
{ name: "", type: "address" },
{ name: "", type: "address" },
{ name: "", type: "uint256" }
],
payable: false,
stateMutability: "view",
type: "function"
},
{
constant: false,
inputs: [],
name: "void",
outputs: [],
payable: false,
stateMutability: "nonpayable",
type: "function"
},
{
constant: false,
inputs: [
{ name: "sellerAddress", type: "address" },
{ name: "amt", type: "uint256" }
],
name: "setSellerAndAmt",
outputs: [],
payable: true,
stateMutability: "payable",
type: "function"
},
{
constant: false,
inputs: [],
name: "escrow",
outputs: [],
payable: false,
stateMutability: "nonpayable",
type: "function"
}
];
var escrowContractAddress = "0x12745f280b67a42eccf4a0ce26c9069727ba4301";
var escrowContract = web3.eth.contract(escrowContractABI);
var escrowContractInstance = escrowContract.at(escrowContractAddress);
var sellerAmountUnconverted;
$("#seller").on("submit", function() {
var sellerAddress = $("#sellerAddress").val();
var sellerAmountUnconverted = parseInt(
document.getElementById("sellerPrice").value
);
var sellerAmountConverted = web3.toWei(sellerAmountUnconverted, "ether");
escrowContractInstance.setSellerAndAmt(
sellerAddress,
sellerAmountConverted,
{
from: web3.eth.accounts[0],
value: web3.toWei(sellerAmountUnconverted, "ether")
},
function(err, result) {
if (!err) {
console.log("succesful");
} else {
alert(err);
}
}
);
});