greymass / anchor

EOSIO Desktop Wallet and Authenticator
https://greymass.com/anchor/
MIT License
569 stars 221 forks source link

Anchor wallet on EOS local test net #1047

Closed tompopovic closed 3 years ago

tompopovic commented 3 years ago

Hi Aaron,

I've been going through the EOS training material, specifically the application developer 101 course on training.eos.io (https://training.eos.io/courses/take/application-developer-101/lessons/17058949-prerequisites-for-this-course).

The course (which I suspect may be outdated content) recommends using Anchor wallet to sign a transaction request on a local EOS development network with the ual-anchor library. Anchor is recommended, as it is one of the few UAL wallets that can support http communication.

I've been banging my head on the wall for a few days trying to get it to work, so I thought I would reach out here to see if you have any suggestions.

Here are the problems I'm having

Attempt #1

After setting up my local network, add all of the accounts and contracts, I attempt to create a custom network (in Anchor):

Submit a signing request via ReactJS app configured with the local network.

No dice, I receive a message that the Blockchain is not configured.

Attempt #2

Instead of using a custom blockchain in Anchor, I add the EOS mainnet and modify the API node URL to my local network address. I then add my private keys to this blockchain.

Submit the signing request, and it works (sometimes).

Unfortunately (and somewhat expectedly), I'm not able to broadcast any transaction on the network. I'm guessing because my local Chain ID doesn't match the EOS mainnet chain id that is hardcoded in Anchor Wallet.

When attempting to sign transactions I will receive errors that I do not have the appropriate permissions to send the transaction on the network (though I can send them through with the same keys on CLEOS).

In addition to the errors about "Blockchain not configured" I also receive errors in Anchor that the signing request is expired immediately.

Now I don't expect you to provide support for developers, however I was wondering if you have any resources on how to connect Anchor to a local test net, and possibly create a Wiki article that may help other developers connect to Anchor wallet using a local test net.

Let me know if you need any more details from me.

Sincerely, Tom

aaroncox commented 3 years ago

Attempt 1 I think is the appropriate path, it's curious it tells you the chain is not configured though.

Have you imported an account for that network, and did it find it? That's one step in configuring Anchor to ensure that it's ready and available to accept signing requests in.

tompopovic commented 3 years ago

Yes, the accounts are discoverable after importing the private keys.

image

image

Following the exact same steps using the EOS mainnet (configured to local network address), does make it past this step and allows me to sign-in, but fails after this point to push transactions.

aaroncox commented 3 years ago

Alright cool - the account should be good then. The EOS logo in the request itself is leading me to believe though that the request heading to the wallet is for EOS, and not the custom chain. Are you specifying the right chain when setting up UAL?

https://github.com/greymass/ual-reactjs-renderer-demo-multipass/blob/master/src/App.js#L32-L49

tompopovic commented 3 years ago

Aha! So it looks like that was my mistake. Here is the code I was using, which was causing the problem:

const ourNetwork = {
  chainID: "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
  rpcEndpoints: [{ protocol: "http", host: "localhost", port: 8888 }]
}

I was specifying 'chainID' instead of 'chainId'. I guess Anchor will, by default, send to EOS when a blockchain is not properly defined.

Here is the corrected code which resolved this issue for me. I'm now able to push signed transactions on my local testnet!

const ourNetwork = {
  chainId: "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
  rpcEndpoints: [{ protocol: "http", host: "localhost", port: 8888 }]
}

I will close off the issue.

Thank you Aaron! I hope to return the favor someday.

aaroncox commented 3 years ago

Ah hah! Yeah, that's caught me off guard a couple times as well. I believe it does default to EOS, though the direction eventually will be to throw an error if a chain is not specifically defined.

The case sensitivity of JS can be both a blessing and a curse sometimes 😉