I'm trying to invoke a constant function test from a webpage. I've injected web3 object through MetaMask.

contract A {
     function test(uint8 x) constant returns(uint8) {
        return x + 10;

My JS code:

var contractA = web3.eth.contract(abiDefinition).at(address);
var retVal = contractA.test(10);

I get an error:

The MetaMask Web3 object does not support synchronous methods

Is there an async version of this api method?

1 Answer 1


If you want to make an asynchronous request, you can pass an optional callback as the last parameter to most functions. All callbacks are using an error first callback style:

 var contractA = web3.eth.contract(abiDefinition).at(address);
 contractA.test(10, function(error, result){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.