Skip to content

APTOS Sign And Submit Transaction

Sign Message Example

typescript
import { Web3Kit, ChainType } from "@web3jskit/dapp";

interface ISignMessageRes {
  signature: string;
}

function signMessage(message: string, display?: "utf8" | "hex") {
  const web3Kit = new Web3Kit();
  const serRes = (await web3Kit.request({
    chainType: ChainType.APTOS,
    methodName: "signAndSubmitTransaction",
    params: {
      function,
      functionArguments,
      typeArguments
    }      
  }));
}

Request Parameters

typescript
//see detail here https://aptos.dev/en/build/sdks/ts-sdk/quickstart#2-build-the-transaction
{
    chainType: ChainType.APTOS,
    methodName: "signAndSubmitTransaction",
    params: {
        function, //string, function name,such as 0x1::aptos_account::transfer_coins
        functionArguments, //Array<string>, function arguments,
        typeArguments
    },
}

Return Value

typescript
{
    hash: "",
    sender: "",
    sequence_number: "",
    max_gas_amount: "",
    gas_unit_price: "",
    expiration_timestamp_secs: "",
    payload: {
        function: "",
        type_arguments: [],
        arguments: [ "", "", "" ],
        type: ""
    },
    signature: {
        public_key: "",
        signature: "",
        type: ""
    }
}