Link Address (non-crypto)

I am not getting the pop up message right now

I switched it to:

    const web3 = async () =>{ 
      await Moralis.enable().then(async () => await Moralis.link(window.ethereum._state.accounts[0]));
    }

This gave me the metamask popup but once signed it did not update database

What version of Moralis SDK are you using?
you can find it out by running: Moralis.CoreManager.get("VERSION")

ā€œmoralisā€: ā€œ^0.0.110ā€,

I have 0.0.124, but your version doesnā€™t look too old.

how do you check what it is in accounts array?

Under the Users object database

if you look at this example that uses react, https://github.com/ethereum-boilerplate/ethereum-boilerplate, does it help you?

Ethereum-Boilerplate says nothing about linking addressesā€¦ I also kind of need to keep it vanilla JS because Iā€™m already connected with login() (non-crypto)

Will I be able to use Moralis.transfer() without an account saved under User?

I think that you should be able to do a transfer without having an address associated with a Moralis account. But you should use Moralis.enableWeb3()

I saw this and I thought that you are not using vanilla js.

my bad itā€™s react, just not react-moralis

@Yomoo do you know how I can make this code update the ā€˜Userā€™ database?

    const web3 = async () =>{ 
      const Moralis = require('moralis')
      await Moralis.enable().then(async () => await Moralis.link(window.ethereum._state.accounts[0]));
    }

I sign the transaction thinking it worked but maybe the problem is Iā€™ve already logged in using login() function from react-moralis (non-crypto)ā€¦ idk

Hi @wesleyt95

What exactly do you want to update in your database?

ethAddress using Moralis.link() function I posted above

Moralis.link updates the database automatically if linking was successful

I sign the transaction thinking it worked but maybe the problem is Iā€™ve already logged in using login() function from react-moralis (non-crypto)ā€¦ idk

[quote=ā€œwesleyt95, post:22, topic:3838ā€]

    const web3 = async () =>{ 
      const Moralis = require('moralis')
      await Moralis.enable().then(async () => await Moralis.link(window.ethereum._state.accounts[0]));
    }

hereā€™s the function Iā€™m using in case u didnā€™t see that either @malik

can you use https://codesandbox.io/ to add your complete code there and test it?
in theory the database should update, in particular this is the code from Moralis SDK:
https://github.com/MoralisWeb3/Moralis-JS-SDK/blob/6b9a6d3a64c94b32f1ec9e7ab609673293439db6/src/MoralisWeb3.js#L131-L134