Skip to content

Can't complete the action because account <account>.testnet doesn't exist #7

@yusufdimari

Description

@yusufdimari

I keep getting this error but if i run the view method on the cli, the deployed contract returns a value.

export const useContract = () => {
const { contract, accountId } = useWallet();
const getBalance = async () => {
if (!contract || !accountId) {
console.error(contract, accountId);
throw new Error("Contract is not initialized");
}
console.log("Contract ID:", contract.contractId);
console.log("Fetching balance for account:", accountId);
try {
const balance = await contract.view("ft_balance_of", {
account_id: accountId,
});
console.log("Balance fetched:", balance);
return balance;
} catch (error) {
console.error("Failed to fetch balance:", error);
throw new Error("Failed to fetch balance. Please try again later.");
}
};
return {
getBalance,
} as const;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions