Skip to main content
edited title
Link
George
  • 131
  • 5

Printing into console: Events TypeError: - 'watch' is not a function

added image
Source Link
George
  • 131
  • 5

Printing into console

I'm checking on my code expression andI need to output theprint out values of the variables.like these green lines:

from ethereum.org

1) Tried returning

When I call a function that returns a string, the hexa transaction address gets printed instead of the function value.

2) Tried js

Referencing this link, I loaded the following js file in hopes to print out variable values.

var abi = /*abi interface*/
var Insurance= web3.eth.contract(abi);
var insurance = Insurance.at(web3.eth.accounts[0]);
var event = insurance.claimInsurance();

// watch for changes
event.watch(function(error, result){
    if (!error)
        console.log(result);
});
event.get(function(error, result){
    if (!error)
        console.log(result);
});

I'm getting err: TypeError: 'watch' is not a function. Is there a way I can print out variables value from the geth console?

Is there a way I can print out variables value from the geth console?

I'm checking on my code expression and need to output the values of the variables. When I call a function that returns a string, the hexa transaction address gets printed instead of the function value.

Referencing this link, I loaded the following js file in hopes to print out variable values.

var abi = /*abi interface*/
var Insurance= web3.eth.contract(abi);
var insurance = Insurance.at(web3.eth.accounts[0]);
var event = insurance.claimInsurance();

// watch for changes
event.watch(function(error, result){
    if (!error)
        console.log(result);
});
event.get(function(error, result){
    if (!error)
        console.log(result);
});

I'm getting err: TypeError: 'watch' is not a function. Is there a way I can print out variables value from the geth console?

Printing into console

I need to print out values like these green lines:

from ethereum.org

1) Tried returning

When I call a function that returns a string, the hexa transaction address gets printed instead of the function value.

2) Tried js

Referencing this link, I loaded the following js file in hopes to print out variable values.

var abi = /*abi interface*/
var Insurance= web3.eth.contract(abi);
var insurance = Insurance.at(web3.eth.accounts[0]);
var event = insurance.claimInsurance();

// watch for changes
event.watch(function(error, result){
    if (!error)
        console.log(result);
});
event.get(function(error, result){
    if (!error)
        console.log(result);
});

I'm getting err: TypeError: 'watch' is not a function.

Is there a way I can print out variables value from the geth console?

Post Reopened by eth
edited tags; edited title
Link
eth
  • 86.5k
  • 53
  • 287
  • 411

How can I do Events TypeError: 'watch' is not a print or console.log in solidity?function

improved question
Source Link
George
  • 131
  • 5
Loading
Post Closed as "Duplicate" by eth
Source Link
George
  • 131
  • 5
Loading