Navigate to the utils Directory and create a new TypeScript file in this directory. You might name it something like getFunction.ts
// src/utils/getFunction.tsimport { aptosClient } from"./aptosClient";exportconstgetFunction=async (accountAddress:string) => {try {constresourceType="0xYourContractAddress::your_module::your_function_name";// Updated to pass an object with the expected propertiesconstresponse=awaitaptosClient().getAccountResource({ accountAddress, resourceType });console.log(response);return response &&response.entries ?true:false; } catch (error) {console.error("Error checking if list exists:", error);returnfalse; }};
Here Replace,
0xYourContractAddress with your contract address (module address)
your_module with your module name (contract name)
your_function_name with your function name you need to call.
Now in App.tsx call the function like this:
The example App.tsx code is:
With this the get function is successfully integrated.
Integrating Aptos Move contracts can be a bit complex, but it is manageable with the right tools and approach. So you are in the right place, this will make it easier to integrate Move contracts.