export async function executeContract()

in cli-functions.js [204:242]


export async function executeContract(config, sender, contract, functionName, args, type = 'path') {
  let configPath = config;

  if (type === 'data') {
    const configFilename = path.join(os.tmpdir(), `config-${crypto.randomUUID()}.tmp`);
    fs.writeFileSync(configFilename, config);
    configPath = configFilename;
  }

  const command = 'rescontract';

  const argList = args.split(',').map((arg) => arg.trim());
  const cliArgs = [
    'execute',
    '--config',
    configPath,
    '--sender',
    sender,
    '--contract',
    contract,
    '--function-name',
    functionName,
    '--arguments',
    argList.join(','),
  ];

  try {
    const result = await handleExecFile(command, cliArgs);
    const success = result.includes("0x0000000000000000000000000000000000000000000000000000000000000001");
    return success ? "Execution successful" : "Execution failed";
    return result;
  } catch (error) {
    throw error;
  } finally {
    if (type === 'data' && fs.existsSync(configPath)) {
      fs.unlinkSync(configPath);
    }
  }
}