application icon indicating copy to clipboard operation
application copied to clipboard

Getting ApplicationID as 0

Open 0xc0d3r opened this issue 6 years ago • 1 comments

const Web3 = require('web3');

const rpcURL = 'https://ropsten.infura.io/v3/<INFURA_PROJECT_ID>';
const contractAddress = '0xcbbfbafedb0eb83016d2a96a4e80d30b20fa3e30';
const email = '[email protected]';
const emailHash =
  '0xbe166c9942e280bb26c7e658bec28539d4b24fc633d8be6d4b005cc204933b84';
const abi = [
  {
    constant: false,
    inputs: [{ name: 'hash', type: 'bytes32' }],
    name: 'apply',
    outputs: [],
    payable: false,
    stateMutability: 'nonpayable',
    type: 'function'
  },
  {
    constant: true,
    inputs: [{ name: 'email', type: 'string' }],
    name: 'getApplicationID',
    outputs: [{ name: '', type: 'uint256' }],
    payable: false,
    stateMutability: 'view',
    type: 'function'
  }
];

const web3 = new Web3(rpcURL);

const contract = new web3.eth.Contract(abi, contractAddress);

contract.methods.apply(emailHash).call((err, result) => {
  contract.methods.getApplicationID(email).call((err, result) => {
    console.log('getApplicationID', result);
  });
});

Am I missing something or is there any problem with the contract?

Did anyone figure it out? Please respond to this.

You can clone and debug here

TIA 🙏🏻

0xc0d3r avatar Feb 04 '20 12:02 0xc0d3r

You need to pay for "non-view" functions :)

janek26 avatar Jun 21 '20 21:06 janek26