Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to EVM-compatible custom network rpc #859

Open
peihsendoyle opened this issue Nov 11, 2022 · 2 comments
Open

Cannot connect to EVM-compatible custom network rpc #859

peihsendoyle opened this issue Nov 11, 2022 · 2 comments

Comments

@peihsendoyle
Copy link

peihsendoyle commented Nov 11, 2022

We are trying to connect our custom network which is EVM-compatible and also metamask compatible as following:
https://docs.kardiachain.io/docs/for-users/wallet/metamask-compatible

RPC_URL: https://rpc.kardiachain.io
CHAIN_ID: 0x18 (integer 24)
EXPLORER_URL: https://explorer.kardiachain.io
SYMBOL: KAI

You can use Metamask to add our network and try to use as normal as Ethereum or BSC which is EVM-compatible as well.

We failed to connect by Web3Auth with following code:

async login() {
      this.web3auth = new Web3Auth({
        clientId: "CLIENT_ID",
        storageKey: "session",
        enableLogging: false,
        uiConfig: {
          loginMethodsOrder: ["facebook", "google"],
        },
        chainConfig: {
          chainNamespace: "eip155",
          chainId: "0x18",
          rpcTarget: "https://rpc.kardiachain.io",
          displayName: "KardiaChain",
          blockExplorer: "https://explorer.kardiachain.io",
          ticker: "KAI",
          tickerName: "KAI",
        },
      });
      const provider = await this.web3auth.connect();
      console.log("provider:", provider);
      const web3 = new Web3(provider);
      const address = (await web3.eth.getAccounts())[0];
      const balance = await web3.eth.getBalance(address);

Error on the console: Invalid network, net_version is 0

@girishvi
Copy link

@yashovardhan Could you please check this ?

Comments from [peihsendoyle]: we notice that our chain id on ChainList is 0
that's why chainId 0x0 works
but cannot send transaction when configure chainId to 0x0

@Saviour1001
Copy link
Contributor

Saviour1001 commented Nov 14, 2022

Hey there, you can just change the chain configurations of this react example and it works. I am able to create the private key and other functions like getBalance, signMessage etc work.

const web3auth = new Web3Auth({
          clientId,
          chainConfig: {
            chainNamespace: CHAIN_NAMESPACES.EIP155,
            chainId: "0x0",
            rpcTarget: "https://rpc.kardiachain.io", // This is the public RPC 
          },
          uiConfig: {
            theme: "dark",
            loginMethodsOrder: ["facebook", "google"],
            defaultLanguage: "en",
            appLogo: "https://web3auth.io/images/w3a-L-Favicon-1.svg", // Your App Logo Here
          },
        });

For sending transactions we are using the libraries ethers/web3, refer to the functions in the example above. Not able to test sendTransaction on my side as I don't have funds on the blockchain, but we are using Web3Auth to get the provider and then we are using external libraries to send transactions so should be working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants