isAuthenticated = true when Im not even signed into Metamask

isAuthenticated = true when Im not even signed into Metamask. Pretty much says it all. How is this possible ?

there is a difference between authentication and metamask, you can authenticate once with metamask and then keep that session opened until you logout, and metamask can be disconnected, or connected to another account in the meantime.

the authentication is like you would authenticate with username and password on gmail, you only authenticate once and then you don’t need to provide that username and password on every click on the site. same here with metamask, you only authenticate once on your local browser.

Then how does it know it’s the same person ? SessionId ? SOme other variable ?

yes, there is a session id saved in cookies on local web browser

omg now Im getting a code 209 invalid session token.

if you logout and log in again it works?

theres something wrong I am doing . Ok in a react application (forget that I am doing typescript) in the index.tsx is where I have

`import React from “react”;
import ReactDOM from “react-dom”;
import { ChakraProvider, theme } from “@chakra-ui/react”;
import { MoralisProvider } from “react-moralis”;
import App from “./App”;
import reportWebVitals from “./reportWebVitals”;

///import Moralis from “moralis/types”;
//import { BrowserRouter } from “react-router-dom”;
//require(‘dotenv’).config();

const appId =“65je0qzIVmARuueC7xIYRf4u2k07BGGoQd8gBqaR”;
const serverUrl = “https://7bsvpeiofxh2.usemoralis.com:2053/server”;

ReactDOM.render(
<React.StrictMode>

  <ChakraProvider theme={theme}>
    <MoralisProvider appId={appId} serverUrl={serverUrl}>
      <App />
    </MoralisProvider>
  </ChakraProvider>

</React.StrictMode>,
document.getElementById(“root”),
);
`

should I have something else after the const serverUrl … line ? like an init or start or something?

Then in my App.tsx I have only this,

import { ChakraProvider } from '@chakra-ui/react';
import theme from "./theme";
import  { ContactUs } from "./components/NewForm";

function App(){

  return (
    <ChakraProvider theme={theme}>
        <ContactUs />
    </ChakraProvider>
  );
}
export default App;

noreference to moralis and again chakra provider? Am I doing something wrong ?

Then in the component ContactUs is my main logic and stuff so I have this

import { useMoralis } from "react-moralis";
 const { Moralis } = useMoralis();

Im getting too confused as to what;'s really going on with the moralis under the hood, trying to put out all these little errors, dancing around trying to fix the error instead of knowing what I am doing ; help !

you include App here, and I think that it is how it will use the appId and serverUrl

but if you use something like import { Moralis } from "moralis"; then you could use Moralis.start separately.

ok you have been a great help. Now I think I get it. but still getting this weird error ever since upgradfing to new server – (also no session is showing in my dashboard no record in session . And some record in a role table that I don’t know what it does )

Uncaught (in promise) Error: Invalid session token

Babel 2

_createSuper ParseError.js:42

ParseError ParseError.js:93

handleError RESTController.js:450

construct.js:25

maybe there are some cookies left in your browser, you could try to logout or to clear all the cookies for localhost

You have been super helpful. I appreciate your patience and help. Now I just have one problem which seems to be not my fault . I keep getting invalid tokenId. when I try to transfer erc20 token. here’s my code



  let options = {
    type: "erc20",
    tokenId: "EVA",
    amount: Moralis.Units.Token(10, 18), 
    receiver: "0xE034873c34EDa00b6D745BBf51cDbBD9d84F3850",
    contractAddress: "0x294e1BFd460053C77B991A3ed22482060b54278A"}
  
    let result = await (Moralis as any).transfer(options);

    console.log(result);

Everything else you said was right so far. You are a web3 guru. But I feel this is on moralis end . I will try other random tokenId but what is the problem with the tokenId

Well it just worked with blank tokenId = “”
I am back in business

1 Like