Skip to main content

📜 4. Gather smart contract information

At this step, you will interact with a smart contract to do daily check-in on the Saigon testnet. To interact with a smart contract, you need to know the following information:

  • Address of the smart contract. In this example, the contract is already deployed at the address 0x9cbc47af3d33aaafbb442cb951dd737a488d693a.
  • ABI (Application Binary Interface) of the smart contract. In short, the ABI is a smart contract's interface in the JSON format. It represents an array of descriptions of functions, events, and errors that the contract exposes. For more information, you can refer to the Solidity documentation.

In this example, you just need to interact with two functions: isMissedCheckIn and checkIn.

The isMissedCheckIn function checks whether the user checked in. It has the following parameters:

  • input: address
  • output: boolean

The function's ABI is as follows:

{
inputs: [
{
internalType: "address",
name: "user",
type: "address",
},
],
name: "isMissedCheckIn",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "view",
type: "function",
}

The checkIn function helps the user check in and has only one parameter as input: address. The function's ABI is as follows:

{
inputs: [
{
internalType: "address",
name: "to",
type: "address",
},
],
name: "checkIn",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
  1. Go to your app directory, then create a folder named check-in.

  2. Create a common.ts to hold common configuration:

    import { getAddress } from "viem"

    export const CHECK_IN_ADDRESS = getAddress("0x9CBC47AF3d33aaAFBb442cB951DD737a488D693A")

    export const CHECK_IN_ABI = [
    {
    inputs: [
    {
    internalType: "address",
    name: "user",
    type: "address",
    },
    ],
    name: "isMissedCheckIn",
    outputs: [
    {
    internalType: "bool",
    name: "",
    type: "bool",
    },
    ],
    stateMutability: "view",
    type: "function",
    },
    {
    inputs: [
    {
    internalType: "address",
    name: "to",
    type: "address",
    },
    ],
    name: "checkIn",
    outputs: [],
    stateMutability: "nonpayable",
    type: "function",
    },
    ] as const

Next step​

5. Get the check-in status of the user