Hello everyone.
I installed moralis:
npm i moralis
npm i @moralisweb3/core @moralisweb3/evm @moralisweb3/evm-api @moralisweb3/evm-wallet-connect-connector @moralisweb3/evm-utils
I use:
node v14.18.0
npm v8.19.2
I use this code:
import Moralis from 'moralis';
import { EvmChain } from '@moralisweb3/evm-utils';
const chain = EvmChain.ETHEREUM;
const address = '0x1234567890123456789012345678901234567890';
await Moralis.start(
{
apiKey: '...'
});
const response = await Moralis.EvmApi.token.getTokenPrice(
{
address,
chain,
});
console.log(' ');
console.log('EvmChain');
console.log(EvmChain);
console.log('response.result');
console.log(response.result);
and got this error:
/../node_modules/@moralisweb3/core/lib/MoralisCoreProvider.js:10
throw new Error_1.MoralisCoreError({
^
MoralisError [Moralis SDK Core Error]: [C0008] Default instance of MoralisCore is not set
at Function.MoralisCoreProvider.getDefault (/../node_modules/@moralisweb3/core/lib/MoralisCoreProvider.js:10:19)
at Function.EvmChain.create (/../node_modules/@moralisweb3/evm-utils/lib/dataTypes/EvmChain/EvmChain.js:211:52)
at Function.get (/../node_modules/@moralisweb3/evm-utils/lib/dataTypes/EvmChain/EvmChain.js:27:29)
at file:///../dev/moralis/EvmApi.js:4:24
at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async Object.loadESM (internal/process/esm_loader.js:68:5) {
isMoralisError: true,
code: 'C0008',
details: undefined
}
How I can fix it?
Thanks.