Send a user operation ( Smart Contract )
spacelisk-js ships with a helper function that builds a transaction by encoding the function data.
import { AA, encodeContractData } from "spacelisk-js"
const pk = "0xprivate_key";
const api_key = "abcd1234";
const account = new AA(api_key, pk).account();
const contractData = encodeContractData({
address: "0x22441385da0f1c4bd08073b322303ae496fbb35c",
functionName: "transfer",
abi: ContractABI,
args: [
"0xc80B282Cc68BF8ee6f70fEc96d1D9f7ab5dc3b3c",
parseEther("0.001")
]
})
const data = await account.sendUserOp(contractData);
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(
contractData,
"0x596c1E3dE33C91c16ee96C7C3Ab7146b99f84717" // Paymaster address
);
console.log("hash:", data.hash)Last updated