getTransactions with "Moralis.User.Current"

Hello

Another quick question.

I want to run the transactions of the current user that is connected via MetaMask. In the documentation it says the address is optional

This is my code:

getTransactions = async () => {
  if(document.querySelector('#get-transactions-link') !=null){
    const transactions = await Moralis.Web3API.account.getTransactions();
    console.log(transactions);
}}

I get this error

main.js:38 Uncaught (in promise) 
{code: 141, error: 'required param address not provided'}
code: 141
error: "required param address not provided"
[[Prototype]]: Object

How can I provide the required param “address” if the user is already signed in via metamask? I tried

const transactions = await Moralis.Web3API.account.getTransactions(Moralis.User.current);

Thanks :smiley:

btw I am again following this guide:

at the video timestamp he says I could just copy that line and it should work

the user has to be authenticated with metamask, or to call Moralis.enableWeb3() for that to work

1 Like

Hello @cryptokid
Thanks for your reply

I do authenticate the user with metamask. I tested this with the command “Moralis.User.current()” as you can see in the screenshot:
snipp

But it wont run the “getTransaction” code…

How do I call to Moralis.enableWeb3() ?
Do you have a link to the documentation? :slight_smile:

Thanks again for your help!

you only write that: Moralis.enableWeb3() before calling Moralis.Web3API.account.getTransactions()
the used address is not from current user, is from web3 connection

1 Like

Thanks man, it took me a while to figure out all the Web3 stuff, but it now works!
I changed the authetification to web3 :slight_smile: