I am trying to call contract by scatter but i met with below error Error is Cannot read property 'find' of undefined

Any other way to call contract and suggestions appretiated!

function gets()
  {  const scatter = window.scatter

    const network = {
        blockchain: 'eos',
        host: 'http://jungle2.cryptolions.io',
        port: 80

      console.log("in gets");
      scatter.getIdentity().then(identity => {
        console.log(identity, "identityFound")
        // do not assign to window in actual projects... only for learning.
        window.identity = identity

      }).catch(error => {
        console.log(error, "identityCrisis!")
        // User "Deny" action

      const accountt =  scatter.identity.accounts.find(x => x.blockchain === 'eos');   
      // Contract calling code goes here.....

2 Answers 2


As @Ami Heines suggested this can be achieve using async nature of js. So define your getScatter action like this and try to define network in a config.json file like I used

  async getScatter(PropsValue) {
    const scatter = PropsValue.scatterObj;
    const { accounts } = await scatter.getIdentity({
      accounts: [config.EOS_CONFIG.network]
    return accounts;

try to avoid pormises.

  • I got it I was previously not getting an account because I was not passing network configurations as parameters now I got it.
    – Mr.Y
    Nov 27, 2018 at 6:09

I suspect you have a timing issue in your code. The javascript code is non blocking and runs in a strange order for programmers coming from a different background.

You are calling getIdentity above but the code keeps on running and trying to use the scatter.identity.accounts without waiting for the result of the call to getIdentity.

Move the line of code with the scatter.identity.accounts.find to right after the identityFound log message. This will only be executed after the process of getting the identity happens.

Your Answer

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

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