Skip to main content
deleted 5 characters in body
Source Link

I have my sample contract as:-

 pragma solidity ^0.4.24;

contract Storage {
  uint256 storedData;
  
  event print(uint256 store);

  function set(uint256 data) public {
    emit print(data);
    storedData = data;
  }

  function get() constant returns (uint256) {
    return storedData;   
  }
}

After setting the value from geth console and mining it, when I use to get a function to check the value it returns the correct value which was set earlier. However when I try to get the event logs with the following code:-

var eve = instance.print({sender:eth.coinbase},{fromBlock: 0, toBlock: "latest"});
var allValues = eve.get();allValues[allValues.length - 1].args;
console.log(allValues[allValues.length - 1].args.store);

Here instance is the contract instance, It shows the error as cannot access member args of undefined.

I have my sample contract as:-

 pragma solidity ^0.4.24;

contract Storage {
  uint256 storedData;
  
  event print(uint256 store);

  function set(uint256 data) public {
    emit print(data);
    storedData = data;
  }

  function get() constant returns (uint256) {
    return storedData;   
  }
}

After setting the value from geth console and mining it, when I use to get a function to check the value it returns the correct value which was set earlier. However when I try to get the event logs with the following code:-

var eve = instance.print({sender:eth.coinbase},{fromBlock: 0, toBlock: "latest"});
var allValues = eve.get();allValues[allValues.length - 1].args;
console.log(allValues[allValues.length - 1].args.store);

Here instance is the contract instance, It shows the error as cannot access member args of undefined.

I have my sample contract as:-

 pragma solidity ^0.4.24;

contract Storage {
  uint256 storedData;
  
  event print(uint256 store);

  function set(uint256 data) public {
    emit print(data);
    storedData = data;
  }

  function get() constant returns (uint256) {
    return storedData;   
  }
}

After setting the value from geth console and mining it, when I use get function to check the value it returns the correct value which was set earlier. However when I try to get the event logs with the following code:-

var eve = instance.print({sender:eth.coinbase},{fromBlock: 0, toBlock: "latest"});
var allValues = eve.get();allValues[allValues.length - 1].args;
console.log(allValues[allValues.length - 1].args.store);

Here instance is the contract instance, It shows the error as cannot access member args of undefined.

Improved title, fixed typo.
Link
user19510
  • 28.1k
  • 2
  • 32
  • 49

Not able to triggerretrieve Solidity event in solidityJavaScript

Event not firing Not able to trigger event in solidity

I have my sample contract as:-

 pragma solidity ^0.4.24;

contract Storage {
  uint256 storedData;
  
  event print(uint256 store);

  function set(uint256 data) public {
    emit print(data);
    storedData = data;
  }

  function get() constant returns (uint256) {
    return storedData;   
  }
}

After setting the value from geth console and mining it, when I use to get a function to check the value it returns the correct value which was set earlier. However when I try to get the event logs with the following code:-

var eve = instance.print({sender:eth.coinbase},{fromBlock: 0, toBlock: "latest"});
var allValues = eve.get();allValues[allValues.length - 1].args;
console.log(allValues[allValues.length - 1].args.store);

Here instance is the contract instance, It shows the error as cannot accesaccess member args of undefined.

Event not firing solidity

I have my sample contract as:-

 pragma solidity ^0.4.24;

contract Storage {
  uint256 storedData;
  
  event print(uint256 store);

  function set(uint256 data) public {
    emit print(data);
    storedData = data;
  }

  function get() constant returns (uint256) {
    return storedData;   
  }
}

After setting the value from geth console and mining it, when I use get function to check the value it returns the correct value which was set earlier. However when I try to get the event logs with following code:-

var eve = instance.print({sender:eth.coinbase},{fromBlock: 0, toBlock: "latest"});
var allValues = eve.get();allValues[allValues.length - 1].args;
console.log(allValues[allValues.length - 1].args.store);

Here instance is the contract instance, It shows the error as cannot acces member args of undefined.

Not able to trigger event in solidity

I have my sample contract as:-

 pragma solidity ^0.4.24;

contract Storage {
  uint256 storedData;
  
  event print(uint256 store);

  function set(uint256 data) public {
    emit print(data);
    storedData = data;
  }

  function get() constant returns (uint256) {
    return storedData;   
  }
}

After setting the value from geth console and mining it, when I use to get a function to check the value it returns the correct value which was set earlier. However when I try to get the event logs with the following code:-

var eve = instance.print({sender:eth.coinbase},{fromBlock: 0, toBlock: "latest"});
var allValues = eve.get();allValues[allValues.length - 1].args;
console.log(allValues[allValues.length - 1].args.store);

Here instance is the contract instance, It shows the error as cannot access member args of undefined.

Source Link
Loading