Skip to main content
Use MiniKit.sendTransaction() to submit one or more World Chain transactions.
These examples assume MiniKit has already been initialized through MiniKitProvider or MiniKit.install().

Availability

  • Works natively in World App
  • Supports Wagmi execution outside World App
  • Batch transactions are only available in World App

Basic Usage

If you used permit2 in MiniKit v1, MiniKit v2 removes that top-level field; Permit2 approvals now need to be sent as explicit transactions
import { MiniKit } from "@worldcoin/minikit-js";
import type {
  CommandResultByVia,
  MiniKitSendTransactionOptions,
  SendTransactionResult,
} from "@worldcoin/minikit-js/commands";

export async function sendTransaction() {
  const input = {
    // Set to 480 for World Chain
    chainId: 480,
    transactions: [
      {
        to: "0x9Cf4F011F55Add3ECC1B1B497A3e9bd32183D6e8",
        data: "0x1234",
      },
    ],
  } satisfies MiniKitSendTransactionOptions;

  const result: CommandResultByVia<SendTransactionResult> =
    await MiniKit.sendTransaction(input);

  console.log(result.data.userOpHash);
}

Result

type SendTransactionResponse =
  | {
      executedWith: "minikit" | "wagmi";
      data: {
        userOpHash: string;
        status: "success";
        version: number;
        from: string;
        timestamp: string;
      };
    }
  | {
      executedWith: "fallback";
      data: unknown;
    };
If you are integrating through Wagmi, viem, or ethers with the World App EIP-1193 provider, the standard eth_sendTransaction call resolves to the MiniKit userOpHash, not a canonical transaction hash. Do not treat the returned value as a final transaction hash or pass it directly to waitForTransactionReceipt. If you need the final on-chain transaction hash, resolve the user operation status first.

Confirming the User Operation

The command resolves as soon as the user operation is submitted, so the first identifier you receive is userOpHash. You can either use @worldcoin/minikit-react hook or poll the Developer Portal to check when the user operation is mined and get the final transaction_hash.
import { useWaitForUserOperationReceipt } from "@worldcoin/minikit-react";
import { createPublicClient, http } from "viem";
import { worldchain } from "viem/chains";

const client = createPublicClient({
  chain: worldchain,
  transport: http("https://worldchain-mainnet.g.alchemy.com/public"),
});

const {
  isLoading,
  isSuccess,
  isError,
  transactionHash,
  receipt,
} = useWaitForUserOperationReceipt({
  client,
  userOpHash,
});
See GET /api/v2/minikit/userop/ for the full endpoint response shape.

Fallback Behavior

If result.executedWith === "wagmi", MiniKit used the standard web signer path outside World App. This path supports only a single transaction, so batched transactions arrays remain World App-only. If you need a different non-World-App flow, provide a custom fallback and handle submission yourself.

Error Codes

CodeMeaning
invalid_operationThe requested operation is not allowed
user_rejectedThe user rejected the request
input_errorThe payload is invalid
simulation_failedSimulation failed before execution
transaction_failedThe transaction failed after submission
generic_errorUnexpected failure
disallowed_operationThe requested operation is disallowed
validation_errorValidation failed before execution
invalid_contractThe contract is not allowed for your app
malicious_operationThe operation was flagged as malicious
daily_tx_limit_reachedDaily transaction limit reached
permitted_amount_exceeds_slippagePermit2 amount exceeds allowed slippage
permitted_amount_not_foundPermit2 amount could not be resolved

Preview