import { InterfaceAbi, ethers } from "ethers";

export const callMethod = async (args: Array<String>, contractAddress: string, functionName: string, abi: InterfaceAbi, provider: ethers.Provider | ethers.Signer) => {

    const contract = new ethers.Contract(contractAddress, abi, provider);

    try {
        const result = await contract[functionName](...args);
        return result;
    } catch (error) {
        return error.reason;
    }
}