If I run the dapp in superblocks I don’t get the balance “0”. What am I doing wrong?
(I tried to copy/paste the code from github, same result.
If I look into the console I get an error (see below).
EDIT: i got it working today
This is my app.js
(function (Contract) {
var web3;
var instance;
function init(cb) {
web3 = new Web3(
(window.web3 && window.web3.currentProvider) ||
new Web3.providers.HttpProvider(Contract.endpoint));
var contract_interface = web3.eth.contract(Contract.abi);
instance = contract_interface.at(Contract.address);
cb();
}
function getBalance() {
instance.getBalance(function (error, result) {
if(error){
alert(error);
}
else{
$("#balance").html(result.toString());
}
});
}
function flip(){
let val = parseInt($("#bet").val());
instance.flip.sendTransaction({from: "0x95c2332b26bb22153a689ae619d81a6c59e0a804", gas:100000, value: val}, function(error, result){
if(error){
alert(error);
}
else{
alert("SUCCESS");
}
})
}
$(document).ready(function () {
init(function () {
getBalance();
});
$("#submit").click(function(){
flip();
})
});
})(Contracts['Coinflip']);
Using Superblocks web3 provider for endpoint: http://superblocks-browser
jquery.js:3818 jQuery.Deferred exception: Cannot read property 'abi' of undefined TypeError: Cannot read property 'abi' of undefined
at init (about:srcdoc:36:61)
at HTMLDocument.<anonymous> (about:srcdoc:65:11)
at mightThrow (https://unpkg.com/[email protected]/dist/jquery.js:3534:29)
at process (https://unpkg.com/[email protected]/dist/jquery.js:3602:12) undefined
jQuery.Deferred.exceptionHook @ jquery.js:3818
process @ jquery.js:3606
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
ready @ jquery.js:3878
completed @ jquery.js:3888
jquery.js:3827 Uncaught TypeError: Cannot read property 'abi' of undefined
at init (VM534 about:srcdoc:36)
at HTMLDocument.<anonymous> (VM534 about:srcdoc:65)
at mightThrow (VM519 jquery.js:3534)
at process (VM519 jquery.js:3602)
init @ VM596 about:srcdoc:36
(anonymous) @ VM596 about:srcdoc:65
mightThrow @ jquery.js:3534
process @ jquery.js:3602
setTimeout (async)
jQuery.readyException @ jquery.js:3826
(anonymous) @ jquery.js:3846
mightThrow @ jquery.js:3534
process @ jquery.js:3602
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
process @ jquery.js:3622
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
ready @ jquery.js:3878
completed @ jquery.js:3888