Reading an ICRC-1 name in JS

Actor creates ok but I cannot call functions on it and get a result.

const token_name = await actor.icrc1_name();

I never see this log^

import { idlFactory } from "../../declarations/token/token.did.js";

document.querySelector("form").addEventListener("submit", async (e) => {
  const button ="button");

  const name = document.getElementById("name").value.toString();

  button.setAttribute("disabled", true);

  const token = "avqkn-guaaa-aaaaa-qaaea-cai"
  const whitelist = [token];
  await window.ic.plug.requestConnect({
        var p = await window.ic.plug.agent.getPrincipal();
        const a = {
          owner: p,
          subaccount: [],
        const actor = await window.ic.plug.createActor({
          canisterId: token,
          interfaceFactory: idlFactory,
        console.log("asking for name")
        const token_name = await actor.icrc1_name();
        try {
        const b = await actor.icrc1_balance_of(a);
      } catch(e) {
        const precision = 100000000n;
        const bal = Number(b * 100000000n / precision) / 100000000;

  // Interact with foo actor, calling the greet method
//  const greeting = await token_lobby_backend.greet(name);


  //document.getElementById("greeting").innerText = greeting;

  return false;

Most ICRC-1 query methods don’t require an identity, this includes the name method. So I would recommend to just create a new HttpAgent without any identity, create an actor with that agent and make those calls.

For calls where you for example transfer funds you can try to use the createActor method from Plug.

Shouldn’t it still work with an identity?

I tried with the identity connect pulled out, same error.