Near web3auth public address

Hi, i am using near chain but i am not able to get account address like someone.near and I am on testnet

  async getAccounts(): Promise<any> {
    try {
      console.log("this.provider", this.provider);

      console.log(this.privateKey, "this . private key");
      const { getED25519Key } = await import("@toruslabs/openlogin-ed25519");
      //   const privateKeyEd25519 = getED25519Key(this.privateKey).sk.toString(
      //     "hex"
      //   );
      console.log(this.privateKey);
      //   console.log(privateKeyEd25519);
      // Get user's Solana's public address
      await this.provider.setupProvider(this.privateKey);
      const privateKeyEd25519Buffer = Buffer.from(this.privateKey, "hex");

      // Convert the private key to base58

      const bs58encode = utils.serialize.base_encode(privateKeyEd25519Buffer);
      console.log("πŸš€ ~ Near ~ getAccounts ~ bs58encode:", bs58encode);

      // Convert the base58 private key to KeyPair
      const keyPair = KeyPair.fromString(`ED25519:${bs58encode}`);
      console.log("πŸš€ ~ NearRpc ~ getAccounts ~ keyPair:", keyPair);

      // publicAddress
      const publicAddress = keyPair?.getPublicKey().toString();
      console.log("πŸš€ ~ NearRpc ~ getAccounts ~ publicAddress:", publicAddress);

      // accountId is the account address which is where funds will be sent to.
      const accountId = utils.serialize.base_decode(
        publicAddress.split(":")[1]
      );
      console.log("πŸš€ ~ NearRpc ~ getAccounts ~ accountId:", accountId);

      let address = Buffer.from(accountId.buffer).toString("hex");
      // publicAddress
      const publicAddress1 = keyPair?.getPublicKey().data || [];
      console.log(
        "πŸš€ ~ NearRpc ~ getAccounts ~ publicAddress1:",
        publicAddress1
      );
      console.log("πŸš€ ~ NearRpc ~ getAccounts ~ address:", address);
      const accountId1 = Buffer.from(bs58encode || []).toString("hex");
      console.log("πŸš€ ~ NearRpc ~ getAccounts ~ accountId1:", accountId1);
      return address;
    } catch (error) {
      console.log("πŸš€ ~ NearRpc ~ getAccounts ~ error:", error);
      throw new Error(error);
    }
  }

can somebody guide me what should I do?

Hi Muhammad Ahmed! Thank you for reaching out with your question about the NEAR chain integration.

From your message, it seems like you’re experiencing an issue with obtaining an account address, specifically you’re not getting the expected format (like someone.near) on the testnet.

Here are the relevant details extracted from your message:

  • SDK Details: Not specified
  • Platform: NEAR chain
  • Issue: Unable to get account address in the format like someone.near on testnet.
  • Code Snippet: You’ve shared your implementation of the getAccounts() function.

In order to assist you better, could you please provide the following additional details?

  1. SDK Version Number: Which version of the SDK are you using?
  2. Web3Auth Initialisation & Login Code Snippets: If you have these snippets, they might help diagnose the issue further.
  3. Browser Console Screenshots: Any relevant errors or logs would be useful.

Additionally, make sure that you have set up your testing environment correctly on the NEAR testnet. Sometimes configuration issues could lead to such challenges.

Once we have this information, the support team can offer more targeted assistance. Thank you!

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

Hey @mahmed10.pk

We don’t have a dedicated Near example, but this file will help in understanding how it can be done with Web3Auth.