Quick start

Submitting Transaction Data

Using the UXLINK Account, you can invoke other contracts to execute custom business logic.

The process for initiating a transaction is as follows:

  1. Submit Execute Data.

  2. Redirect to the user password verification page, where the user enters their password. Upon successful verification, the transaction is sent to the blockchain.

  3. After the transaction is executed, callback to replaceUrl and query the transaction result through the order query interface.

1. Submitting an Order

The interface for submitting an order is as follows: POST /oneAccount/v1/sendExecuteData

Request Body:

{
  executeData: {
      to: "0x.....", // Address of the business contract to be called
      data: "...", // Encoded string containing the function name to be executed in the contract and the arguments passed to this function. Method for creating executeData will be provided below.
  },
}

Response:

{
    orderId: "...", // ID of this transaction, which can be used to query the transaction result.
}

1.1 Generating executeData

Creating executeData requires the ABI of the corresponding business contract. As this file is too large to be conveniently passed through the interface, it needs to be generated by the project side. Here is a function for generating it:

import { ethers } from "ethers";

const rpc = ""; // TODO: Modify the RPC link used here
const provider = new ethers.providers.JsonRpcProvider(rpc);

/**
 * @param contractAddress Contract address
 * @param contractABI ABI of the contract
 * @param executeFunctionName Name of the function to be executed
 * @param executeFunctionArgs Arguments to be passed to the function
 */
createExecuteData(contractAddress: string, contractABI: any[], executeFunctionName: string, executeFunctionArgs: any[]) {
  const contract = new ethers.Contract(contractAddress, contractABI, provider);
  return {
    to: contractAddress,
    data: contract.interface.encodeFunctionData(executeFunctionName, executeFunctionArgs),
  };
}

2. Redirecting to the User Password Verification Page

After obtaining the orderId, redirect to:

https://oneAccount.uxlink.io/confirmExecuteData?orderId=ORDER_ID&replaceUrl=YOUR_REDIRECT_URI

Upon the user entering the password on the verification page and successful validation by the server, the transaction data corresponding to this orderId will be submitted to the blockchain for execution of the relevant business logic.

3. Querying Transaction Results

Upon successful execution of the transaction after the user enters the password on the verification page, the page will redirect to replaceUrl with the orderId.

To query the execution result, use the transaction status query interface:

Interface: /aaWallet/v1/getTransactionResult

Request Body:

{
    orderId: "...",
}

Response:

// Success:
{
    orderId: "",
    transactionHash: "",
}

// Failure:
{
    orderId: "",
    error: "", // Error message
}

Last updated

Was this helpful?