title: Solana Rust (Anchor): TypeError: Cannot read properties of undefined (reading '_bn')
body: <p>I'm trying to build a simple application with React that interacts with my Solana smart contract. When I click the <code>&lt;button&gt;</code> which calls <code>getMsg()</code> function, the following error is displayed.</p>
  <pre><code>TypeError: Cannot read properties of undefined (reading '_bn')
      at isPublicKeyData (index.browser.esm.js?58d5:1777:1)
      at new PublicKey (index.browser.esm.js?58d5:1795:1)
      at T (index.js?c657:1:1828)
      at An.getAccountInfo (index.js?c657:16:47072)
      at An.fetchNullable (index.js?c657:16:45149)
      at An.fetch (index.js?c657:16:45284)
      at _callee3$ (index.js?44d8:57:58)
      at tryCatch (regeneratorRuntime.js?7ec2:86:1)
      at Generator.eval [as _invoke] (regeneratorRuntime.js?7ec2:66:1)
      at Generator.eval [as next] (regeneratorRuntime.js?7ec2:117:1)
      at asyncGeneratorStep (asyncToGenerator.js?1da1:3:1)
      at _next (asyncToGenerator.js?1da1:25:1)
  </code></pre>
  <hr />
  <p>Contract</p>
  <pre><code>use anchor_lang::prelude::*;
  
  declare_id!( &lt;=== omitted ===&gt; );
  
  #[program]
  pub mod greeting {
  
      use super::*;
  
      pub fn execute(ctx: Context&lt;Execute&gt;, name: String) -&gt; Result&lt;()&gt; {
          let gm_account = &amp;mut ctx.accounts.gm_account;
          gm_account.name = name;
          msg!(&quot;hello {}&quot;, gm_account.name);
          Ok(())
      }
  
  }
  
  #[derive(Accounts)]
  pub struct Execute&lt;'info&gt; {
      #[account(init, payer = user, space = 8 + 32)]
      pub gm_account: Account&lt;'info, GreetingAccount&gt;,
  
      #[account(mut)]
      pub user: Signer&lt;'info&gt;,
      pub system_program: Program&lt;'info, System&gt;,
  }
  
  #[account]
  pub struct GreetingAccount {
      pub name: String,
  }
  </code></pre>
  <hr />
  <p>React:</p>
  <pre><code>  const programId = new PublicKey(idl.metadata.address);
  
    const getMsg = async () =&gt; {
      try {
        const provider = getProvider();
        const program = new Program(idl, programId, provider);
        await program.rpc.execute(&quot;a test message&quot;, {
          accounts: {
            gmAccount: greetingAccount.publicKey,
            user: provider.wallet.publicKey,
            systemProgram: SystemProgram.programId
          },
          signers: [greetingAccount]
        });
  
        const name = await program.account.greetingAccount.fetch();
      } catch (e) {
        console.error(e);
      }
    };
  </code></pre>
  <hr />
  <p>Idl</p>
  <pre><code>{
    &quot;version&quot;: &quot;0.1.0&quot;,
    &quot;name&quot;: &quot;greeting&quot;,
    &quot;instructions&quot;: [
      {
        &quot;name&quot;: &quot;execute&quot;,
        &quot;accounts&quot;: [
          {
            &quot;name&quot;: &quot;gmAccount&quot;,
            &quot;isMut&quot;: true,
            &quot;isSigner&quot;: true
          },
          {
            &quot;name&quot;: &quot;user&quot;,
            &quot;isMut&quot;: true,
            &quot;isSigner&quot;: true
          },
          {
            &quot;name&quot;: &quot;systemProgram&quot;,
            &quot;isMut&quot;: false,
            &quot;isSigner&quot;: false
          }
        ],
        &quot;args&quot;: [
          {
            &quot;name&quot;: &quot;name&quot;,
            &quot;type&quot;: &quot;string&quot;
          }
        ],
        &quot;returns&quot;: null
      }
    ],
    &quot;accounts&quot;: [
      {
        &quot;name&quot;: &quot;GreetingAccount&quot;,
        &quot;type&quot;: {
          &quot;kind&quot;: &quot;struct&quot;,
          &quot;fields&quot;: [
            {
              &quot;name&quot;: &quot;name&quot;,
              &quot;type&quot;: &quot;string&quot;
            }
          ]
        }
      }
    ],
    &quot;metadata&quot;: {
      &quot;address&quot;: &quot; &lt;== omitted ==&gt; &quot;
    }
  }
  
  </code></pre>