Smart contract interactions

Send transaction request

The Send Contract Transaction action enables you to interact with a smart contract by sending a transaction to a specified contract address. It utilizes a JSON stringified representation of the contract's ABI (Application Binary Interface), focusing specifically on the function you intend to call. Although you can provide the complete ABI, it is recommended to include only the specific function being called for better optimization.

Action Parameters:

  • Contract Address: The address of the smart contract.

0x35214dc712C4F1571ec7F6cf957c3050ca8e863D
[
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "_to",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "_tokenId",
                "type": "uint256"
            },
            {
                "internalType": "uint256",
                "name": "_amount",
                "type": "uint256"
            },
            {
                "internalType": "bytes",
                "name": "data",
                "type": "bytes"
            }
        ],
        "name": "mint",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    }
] // example
  • Function Name: The name of the function being called in the ABI

mint
  • Input Data: A JSON stringified representation of the input data required for the function call. Example format:

"{'_to':'123','_tokenId':1,'_amount':1}"
  • Chain ID: The target chain ID (in decimals) specifies the blockchain network where the transaction will be sent. https://chainlist.org/

Process Flow:

  1. Transaction Status Management: Throughout the process, the transaction status is updated to provide feedback on the state of the transaction:

    • The status is initially set to "pending" when the transaction begins.

    • After sending the transaction, the action enters a waiting state to monitor for confirmation from the blockchain.

    • If the transaction is confirmed successfully, the status is updated to "success".

    • If the transaction fails or is reverted, the status is set to "error", and an appropriate error message is logged.

  2. Gas Estimation and Execution: The action estimates the gas required for the transaction using the specified function and input data, ensuring that the transaction proceeds efficiently.

  3. Transaction Confirmation: The action monitors the transaction confirmation using a polling mechanism with a timeout of 120 seconds. If the transaction is not confirmed within this period, the process throws a timeout error.

  4. Error Handling: Any errors encountered during the transaction process are caught, and the status is set to "error", ensuring that the user is notified of the failure.

Example of sending mint transaction request:

Once the transaction is successfully sent and confirmed, the action updates the Last Transaction Hash, which can be retrieved using the Get Last Transaction Hash expression. Additionally, the On Transaction Sent condition is triggered, indicating that the transaction has been successfully processed and confirmed.

Transaction Status

The Set Transaction Status action allows you to manually update the internal status of the transaction. This can be useful for debugging or custom logic where you need to set a specific status based on the flow of your application.

  • Parameter:

    • Status: A string representing the new status of the transaction (e.g., "pending", "success", "error").

The Get Transaction Status expression retrieves the current status of the last transaction processed. It returns the status as a string, allowing you to check if a transaction is pending, successful, or has encountered an error. This expression is useful for displaying the status or making decisions based on the transaction outcome.

Read data request

The Read Contract Data action allows you to interact with a smart contract by calling a function and reading data from it. This action uses a JSON stringified representation of the contract's Application Binary Interface (ABI) and focuses on the function you want to read from. While you can provide the entire ABI, it is recommended to only include the specific function being called to optimize the request by reducing unnecessary data.

Action Parameters:

  • Contract Address: The address of the smart contract.

0x35214dc712C4F1571ec7F6cf957c3050ca8e863D
  • ABI: A JSON stringified representation of the ABI (Application Binary Interface)

[
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "_tokenId",
                "type": "uint256"
            }
        ],
        "name": "tokenMaxMints",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    }
] // example
  • Function Name: The name of the function being called in the ABI

tokenMaxMints
  • Input Data: A JSON stringified representation of the input data required for the function call. Example format:

"[['0x6CBa743401e000eb29d17d6f3406CA0143e38203'], [1]]"
  • RPC URL: The URL of the Remote Procedure Call (RPC) endpoint for interacting with the blockchain. https://chainlist.org/

Once the data is successfully read, the action updates the last read contract data, which can be retrieved using the Get Last Read Contract Data expression. Additionally, the On Contract Data Received condition is triggered, indicating that the data has been successfully retrieved from the contract.

Example of read action:

Once the data is successfully read, the action updates the last read contract data, which can be retrieved using the Get Last Read Contract Data expression. Additionally, the On Contract Data Received condition is triggered, indicating that the data has been successfully retrieved from the contract.

Read multiple data request

The Read Multiple Contract Data action allows for reading data from multiple functions of a smart contract in a single request. This is particularly useful when you need to fetch various pieces of data from a contract without making multiple separate requests, thus improving efficiency

The action takes several parameters:

  • Contract Address: The address of the smart contract to interact with.

0x35214dc712C4F1571ec7F6cf957c3050ca8e863D
  • ABI: A JSON stringified representation of the contract's ABI (Application Binary Interface). The ABI defines the functions and events of the contract.

[
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "_tokenId",
                "type": "uint256"
            }
        ],
        "name": "tokenMaxMints",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "address",
                "name": "_wallet",
                "type": "address"
            },
            {
                "internalType": "uint256",
                "name": "_tokenId",
                "type": "uint256"
            }
        ],
        "name": "walletMintsOf",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    }
] // example
  • Function Names: A JSON stringified array containing the names of the functions to call. Each function should be present in the provided ABI.

"['tokenMaxMints','walletMintsOf']"
  • Inputs Data: A JSON stringified array where each element corresponds to the input data for each function being called. The input data should match the number and order of arguments expected by each function.

"[[1],['"&userAccount&"', 1]]"

Example of multiple read action:

Once the data is successfully read, the action updates the last multiple-read contract data, which can be retrieved using the Get Multiple Last Read Contract Data expression. Additionally, the On Multiple Contract Data Received condition is triggered, indicating that the data has been successfully retrieved from the contract.

Life scenario based on the shop functionality

Last updated