Entry Function Integration

Write into the block

frontend/
    ├───components
    │   └───ui
    ├───entry-functions
    ├───lib
    ├───utils
    ├───view-functions
    ├───App.tsx
    ├───index.tsx

First navigate to the entry-functions Directory and create a new TypeScript file in this directory. You might name it something like integrateContract.ts.

import { InputTransactionData } from "@aptos-labs/wallet-adapter-react";

// Function to create an entry with the new arguments
export type CreateArguments = {
  name: string;
  timestamp: string;
};

export const createEntry = (args: CreateArguments): InputTransactionData => {
  const { name, timestamp } = args;
  return {
    data: {
      function: "0xYourContractAddress::your_module::your_function_name", // Replace with your actual contract address and module::function name
      functionArguments: [name, timestamp],
    },
  };
};

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.

Here's how you can set up main.tsx with QueryClientProvider and the necessary imports:

npm install @tanstack/react-query

Then in App.tsx the function createEntry should be called like this

Import these modules to integrate successfully

Initialize useQueryClient like this:

This is the function to handle the transaction

Then just call the function in like you normally do

Example App.tsx

Output

Now the move contract is successfully integrated

Last updated