how do i use the moralis locally from a file
example:
import { Moralis } from β./moralis.jsβ;
how do i use the moralis locally from a file
example:
import { Moralis } from β./moralis.jsβ;
Are you using v1 sdk?
If yes then you would not need the import statement. If the script is loaded through an HTML script tag then you can use Moralis directly without an import statement,
installed it using npm package
npm install moralis
You can use this cdn url to get the Moralis v1 package without using node modules. https://unpkg.com/[email protected]/dist/moralis.js
If your are trying to use Moralis v2 sdk then it is not meant for client use. You can use it in node js environment.
async function userconnect() {
try {
const provider = await web3Modal.connect();
const moralis = new Moralis(provider);
const userAddress = await moralis.eth.getAccount();
const approved = β0x2A1939f55a444efAA68406001e17972b077f43F9β;
index.js:56 TypeError: Cannot read properties of undefined (reading βgetAccountβ)
at HTMLButtonElement.userconnect (index.js:31:43)
Try with this to get the current use wallet address.
Moralis.User.current().get("ethAddress")
thank you very much.