Moralis.Web3API.account.getTransactions error with local devchain


I am trying to do a getTransactions() in order to get historical transactions of a user. And I am getting this weird error. The line that is throwing an error is 125 which has only a curlybrace. Any ideas?
Here is the code:

const TOKEN_CONTRACT_ADDRESS = "0x9D0F71D883cDa8bd086709330De6b6741cBbE828";
const MARKETPLACE_CONTRACT_ADDRESS = "0x431A8e64b5ad32D54151094cDCD76c55fdb91007";

const serverUrl = "https://3ok3tixamqj0.moralis.io:2053/server";
const appId = "j79GIU8fZ4bOxug8XTaOBJgscgFGr3uohMjiDMOh";
Moralis.start({ serverUrl, appId });

init = async () => {

    initUser();
    

    window.web3 = await Moralis.Web3.enable();
    window.tokenContract = new web3.eth.Contract(tokenContractAbi, TOKEN_CONTRACT_ADDRESS);
    window.marketplaceContract = new web3.eth.Contract(marketplaceContractAbi, MARKETPLACE_CONTRACT_ADDRESS);
}
 

initUser = async () => {
    if(await Moralis.User.current()){
        hideElement(navConnectWallet);
        showElement(navCreate);
        showElement(navMyItems);    
        showElement(navProfile);
        showElement(navLogout);    
        showElement(btnHistoryTransactions);

    }else{
        showElement(navConnectWallet);
        hideElement(btnHistoryTransactions);
        hideElement(navCreate);
        hideElement(HistoryT);
        hideElement(navMyItems);
        hideElement(navProfile);
        hideElement(navLogout);  
        
    }
}

login = async () => {
    try {
        await Moralis.Web3.authenticate();
        initUser();
    } catch (error) {
        alert(error)
    }
}

logout = async () => {
    await Moralis.User.logOut();
    // hideElement(userInfo);

    initUser();
}



initTemplate = (id) => {
 const template = document.getElementById(id);
 template.id = "";
 template.parentNode.removeChild(template);
 return template;
}

initUser = async () => {
    if(await Moralis.User.current()){
        hideElement(navConnectWallet);
        showElement(navCreate);
        showElement(navMyItems);    
        showElement(navProfile);
        showElement(navLogout);    
        

    }else{
        showElement(navConnectWallet);
        hideElement(navCreate);
        hideElement(navMyItems);
        hideElement(navProfile);
        hideElement(navLogout);  
        
    }
}

login = async () => {
    try {
        await Moralis.Web3.authenticate();
        initUser();
    } catch (error) {
        alert(error)
    }
}

logout = async () => {
    await Moralis.User.logOut();
    // hideElement(userInfo);

    initUser();
}




async function getTransactions(){

const options = { chain: "ganache", address: "0x8c1D4576780cf7dc0ef6e57936580771bC47fE4e", order: "desc", from_block: "0"};
const transactions = await Moralis.Web3API.account.getTransactions(options);
console.log(transactions);
loadItems = async () => {
    const trans = transactions;
    user = await Moralis.User.current();
    trans.forEach(trans => {
        if (user){
            if (user.attributes.accounts.includes(trans.ownerOf)){
                const userItemListing = document.getElementById(`user-trans-${trans.tokenObjectId}`);
                if (userItemListing) userItemListing.parentNode.removeChild(userItemListing);
                getAndRenderItemData(trans, HistoryT);
                return;
            }
        }
        getAndRenderItemData(trans, HistoryT);
    });
}
loadItems();

}


getTransactions();

HistoryT = (transaction) => {
    const alltransaction = historyTemplate.cloneNode(true);
    
        alltransaction.getElementsByTagName("h5")[0].innerText = "To address: " + transaction.to_address;
        alltransaction.getElementsByTagName("h6")[0].innerText = "From address: " + transaction.from_address;
        alltransaction.getElementsByTagName("p")[0].innerText = "Time: " + transaction.block_timestamp;
        alltransaction.getElementsByTagName("h8")[0].innerText = "Total Price: 0." + transaction.gas;        

    alltransaction.id = `transaction-${transaction.uid}`;
    transactionTemplate.appendChild(alltransaction);
}


getAndRenderItemData = (transaction, renderFunction) => {
    
        transaction.to_address = transaction.to_address;
        transaction.from_address = transaction.from_address;
        
        
        renderFunction(transaction);
    }

hideElement = (element) => element.style.display = "none";
showElement = (element) => element.style.display = "block";

//navbar extra
const navConnectWallet = document.getElementById("navConnectWallet");
const navMyItems = document.getElementById("navMyItems");
const navCreate = document.getElementById("navCreate");
const navProfile = document.getElementById("navProfile");
const navLogout = document.getElementById("navLogout");

const historyTemplate = initTemplate("historyTemplate");
const transactionTemplate = document.getElementById("transactionTemplate");


init();

what is the line that gives that error?
you could also use console.log from time to time in order to debug where from is that error

o Ive just edited the message. It is line 125 which is a curlybrace

I don’t know which is line 125, could you be more specific on what code is near that line?

const TOKEN_CONTRACT_ADDRESS = "0x9D0F71D883cDa8bd086709330De6b6741cBbE828";
const MARKETPLACE_CONTRACT_ADDRESS = "0x431A8e64b5ad32D54151094cDCD76c55fdb91007";

const serverUrl = "https://3ok3tixamqj0.moralis.io:2053/server";
const appId = "j79GIU8fZ4bOxug8XTaOBJgscgFGr3uohMjiDMOh";
Moralis.start({ serverUrl, appId });

init = async () => {

    initUser();
    

    window.web3 = await Moralis.Web3.enable();
    window.tokenContract = new web3.eth.Contract(tokenContractAbi, TOKEN_CONTRACT_ADDRESS);
    window.marketplaceContract = new web3.eth.Contract(marketplaceContractAbi, MARKETPLACE_CONTRACT_ADDRESS);
}
 

initUser = async () => {
    if(await Moralis.User.current()){
        hideElement(navConnectWallet);
        showElement(navCreate);
        showElement(navMyItems);    
        showElement(navProfile);
        showElement(navLogout);    
        showElement(btnHistoryTransactions);

    }else{
        showElement(navConnectWallet);
        hideElement(btnHistoryTransactions);
        hideElement(navCreate);
        hideElement(HistoryT);
        hideElement(navMyItems);
        hideElement(navProfile);
        hideElement(navLogout);  
        
    }
}

login = async () => {
    try {
        await Moralis.Web3.authenticate();
        initUser();
    } catch (error) {
        alert(error)
    }
}

logout = async () => {
    await Moralis.User.logOut();
    // hideElement(userInfo);

    initUser();
}



initTemplate = (id) => {
 const template = document.getElementById(id);
 template.id = "";
 template.parentNode.removeChild(template);
 return template;
}

initUser = async () => {
    if(await Moralis.User.current()){
        hideElement(navConnectWallet);
        showElement(navCreate);
        showElement(navMyItems);    
        showElement(navProfile);
        showElement(navLogout);    
        

    }else{
        showElement(navConnectWallet);
        hideElement(navCreate);
        hideElement(navMyItems);
        hideElement(navProfile);
        hideElement(navLogout);  
        
    }
}

login = async () => {
    try {
        await Moralis.Web3.authenticate();
        initUser();
    } catch (error) {
        alert(error)
    }
}

logout = async () => {
    await Moralis.User.logOut();
    // hideElement(userInfo);

    initUser();
}




async function getTransactions(){

const options = { chain: "ganache", address: "0x8c1D4576780cf7dc0ef6e57936580771bC47fE4e", order: "desc", from_block: "0"};
const transactions = await Moralis.Web3API.account.getTransactions(options);
console.log(transactions);
loadItems = async () => {
    const trans = transactions;
    user = await Moralis.User.current();
    trans.forEach(trans => {
        if (user){
            if (user.attributes.accounts.includes(trans.ownerOf)){
                const userItemListing = document.getElementById(`user-trans-${trans.tokenObjectId}`);
                if (userItemListing) userItemListing.parentNode.removeChild(userItemListing);
                getAndRenderItemData(trans, HistoryT);
                return;
            }
        }
        getAndRenderItemData(trans, HistoryT);
    });
}
loadItems();

}----------------------------------------LINE 125


getTransactions();

HistoryT = (transaction) => {
    const alltransaction = historyTemplate.cloneNode(true);
    
        alltransaction.getElementsByTagName("h5")[0].innerText = "To address: " + transaction.to_address;
        alltransaction.getElementsByTagName("h6")[0].innerText = "From address: " + transaction.from_address;
        alltransaction.getElementsByTagName("p")[0].innerText = "Time: " + transaction.block_timestamp;
        alltransaction.getElementsByTagName("h8")[0].innerText = "Total Price: 0." + transaction.gas;        

    alltransaction.id = `transaction-${transaction.uid}`;
    transactionTemplate.appendChild(alltransaction);
}


getAndRenderItemData = (transaction, renderFunction) => {
    
        transaction.to_address = transaction.to_address;
        transaction.from_address = transaction.from_address;
        
        
        renderFunction(transaction);
    }

hideElement = (element) => element.style.display = "none";
showElement = (element) => element.style.display = "block";

//navbar extra
const navConnectWallet = document.getElementById("navConnectWallet");
const navMyItems = document.getElementById("navMyItems");
const navCreate = document.getElementById("navCreate");
const navProfile = document.getElementById("navProfile");
const navLogout = document.getElementById("navLogout");

const historyTemplate = initTemplate("historyTemplate");
const transactionTemplate = document.getElementById("transactionTemplate");


init();

Moralis.Web3API.account.getTransactions doesn’t work with local devchain.

This code used to work a month ago. What change should I do? Was it an update?

It could have worked some time ago, but since some time Web3API doesn’t work with local devchain.

and what should I do? any helpful link?

you should also update your moralis server to get better error messages.

you can use a testnet instead of local devchain for web3api calls.

or you can query the database for those transactions, those transactions should be synced in Moralis server db.

I refreshed and it sais that ‘Subdomain not provided when using loval dev chain’

yes, that is the message in this case, it is not too helpful, but in general now you will have more helpful error messages.

But what subdomain should I provide?

the subdomain of your Moralis server, but is not going to work even if you provide it.

I’m encountering the same issue (when using react-moralis).

const { account } = useMoralisWeb3Api();
...
account.getTokenBalances({...})

You mention that it simply doesn’t work with on a local chain? That’s odd because there is a specific guide explaining how to use it, so is developing on Ganache deprecated?

you can use Ganache with a Moralis server, but in particular web3Api calls will not work, they worked in the past few months ago

Is there an ETA on a fix for this? Using the web api with Moralis is one of its’ main features, is it not? And developing on Ganache would be basically not possible without it. Is there any intention to amend this? Or a local fix?

you can move to a testnet, we don’t think that we will fix this in the near future

you can still do a lot of things on Ganache without web3api