I have a working contract that I made in ether.camp with solidity, it functions as desired through the IDE contract interface and now I am trying to tie it into an html GUI with web3.
To this end I have been following a series of tutorials, but as far as I can see - what I am doing should be working but it looks like it is not connecting to the contract?
Html:
<form>
<button id="call" type="submit">Call</button>
</form>
<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<script src="dist/app.js"></script>
app.js
var async = require('async');
var Web3 = require('web3');
var ethTx = require('ethereumjs-tx');
var SolidityFunction = require('web3/lib/web3/function');
var abi = [{
"name": "removeElement(address)",
"type": "function",
"inputs": [
{
"name": "key",
"type": "address"
}
]
}];
var sandboxId = '<my sandbox id>';
var url = 'https://<my user>.by.ether.camp:8555/sandbox/' + sandboxId;
var web3 = new Web3(new Web3.providers.HttpProvider(url));
web3.eth.defaultAccount = '0xdedb49385ad5b94a16f236a6890cf9e0b1e30392';
$( "button" ).click(function() {
alert("button was clicked"); //just checking the jquery was working
var contract = web3.eth.contract(abi).at('0x17956ba5f4291844bc25aedb27e69bc11b5bda39'); //The contract address as per the ethercamp IDE
contract.call().removeElement("0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba");
});
The removeElement(address key)
function in the contract works absolutley fine from the IDE. I suspect the above code is not actually 'connecting' to the contract? Wish I could be more detailed but I'm not sure whats not working here
Thank you!
contract.call().removeElement("0x2ad...");
looks strange to me. I am more used to seeingcontract.removeElement.call("0x2ad...");
orcontract.removeElement("0x2ad...");
.call()
- repositioning it still seems to do nothing :(call()
does not seem to work. I get thealertbox
fine showing the button click is being triggered but nothing happens to the contract. Doing the exact sameremoveElement
in the IDE works - just not from web3var contract = web3.eth.contract(abi).at('0x179...');
thencontract.removeElement()
and see what comes out.ReferenceError: web3 is not defined
but we can see above that I am ?