Login to Solana Phantom Wallet

Hello I’m trying to connect with Phantom Wallet using this piece of code i’ve found there:https://docs.moralis.io/moralis-server/users/crypto-login

Moralis.authenticate({type:‘sol’}).then(function(user) {
console.log(user.get(‘solAddress’))
})

but i got an error:
Type ‘“sol”’ is not assignable to type ‘AuthenticationType | undefined’.

im using moralis version 0.0.134, angular 12.2 and node 14.10

you could try a newer version of Moralis SDK, latest seems to be 0.0.176, you may also need latest version of Moralis server

I tried installing Moralis version 0.0.176 but i got an error:

  1. syncNFTContract: (options: operations[“syncNFTContract”][“parameters”][“query”] & operations[“syncNFTContract”][“parameters”][“path”]) => Promise<operations[“syncNFTContract”][“responses”][“200”][“content”][“application/json”]>;

in the file: node_modules/moralis/types/generated/web3Api.d.ts:1970:194

what did you do to get that error?

i installed moralis with npm install moralis@latest
then
use functions:

loginWithMetamask() {
Moralis.Web3.authenticate({ provider: ‘metamask’ })
.then((loggedInUser) => {
this.setLoggedInUser(loggedInUser);
this.getUserNFTs();
})
.catch((e) => console.error(Moralis metamask login error:, e));
}

loginWalletConnect() {
Moralis.Web3.authenticate({ provider: ‘walletconnect’ })
.then((loggedInUser) => {
console.log(“loggedInUser wallet connect”, loggedInUser)
this.setLoggedInUser(loggedInUser);
this.getUserNFTs();
})
.catch((e) => console.error(Moralis walletconnect login error:, e));
}

then ng serve

and if you comment this line?

its ok i managed installing version 0.0.176 by commenting this line in the file web3Api.d.ts of the moralis module:
syncNFTContract: (options: operations[“syncNFTContract”][“parameters”][“query”] & operations[“syncNFTContract”][“parameters”][“path”]) => Promise<operations[“syncNFTContract”][“responses”][“200”][“content”][“application/json”]>;

the 200 is causing the error

but this Moralis.Web3.authenticate({type:‘sol’}).then(function(user) {
console.log(user.get(‘solAddress’))
}) still shows the same error

in the index.d.ts of the module there is these lines:
type Web3ProviderType = ‘metamask’ | ‘walletconnect’ | ‘walletConnect’ | ‘wc’;
type AuthenticationType = ‘evm’ | ‘dot’ | ‘polkadot’ | ‘kusama’ | ‘erd’ | ‘elrond’;
type Web3Provider = MoralisWalletConnectProvider | MoralisInjectedProvider;
interface AuthenticationOptions {
provider?: Web3ProviderType;
type?: AuthenticationType;
chainId?: number;
signingMessage?: string;
}

sol is not supported anymore ?

maybe it is an error related to typescript, I think sol authentication should be a recent addition

thanks noted, yeah must be just typescript issue, will update it soon. For now if you are using typescript, you can just // @ts-ignore on top of the Moralis.authenticate line

to use the type sol i had to add it in the node_modules file

I don’t recommend you to touch anything in node_modules, coz you might modify it, but in production you will not be able to do so. However, based on your feedback, I already added sol to the typescript support in v0.0.178. Make sure you update your Moralis SDK to at least that version and you’ll be able to use the sol type :raised_hands: