Send a user operation

Sending a user operation. This is a simple user operation that sends 0.001 ETH to 0xc80B282Cc68BF8ee6f70fEc96d1D9f7ab5dc3b3c. Here the user is responsibe for paying for transaction gas.

import { AA } from "spacelisk-js"

const pk = "0xprivate_key";
const api_key = "abcd1234";

const account = new AA(api_key, pk).account();

const data = await account.sendUserOp({
    to: "0xc80B282Cc68BF8ee6f70fEc96d1D9f7ab5dc3b3c",
    value: parseEther("0.001")
});

console.log("hash:", data.hash)

If you want to use a paymaster, you can pass the paymaster address as a second argument to sendUserOp.

const data = await account.sendUserOp(
    {
     to: "0xc80B282Cc68BF8ee6f70fEc96d1D9f7ab5dc3b3c",
     value: parseEther("0.001")
    },
    "0x596c1E3dE33C91c16ee96C7C3Ab7146b99f84717" // Paymaster address
);

console.log("hash:", data.hash)

Last updated