sendTransaction
sendTransaction
is a method on AccountSigner
that sends transactions on behalf of the AccountSigner
's smart account, with request and response formatted as if you were using the ethers.js library.
Note that to
field of transaction is required, and among other fields of transaction, only data
, value
, maxFeePerGas
, maxPriorityFeePerGas
fields are considered and optional. Support for other fields is coming soon.
Usage
import { accountSigner } from "./ethers-signer";
const txHash = await accountSigner.sendTransaction({
from, // ignored
to,
data: encodeFunctionData({
abi: ContractABI.abi,
functionName: "func",
args: [arg1, arg2, ...],
}),
});
import { createLightAccount } from "@alchemy/aa-accounts";
import {
LocalAccountSigner,
SmartAccountSigner,
polygonMumbai,
} from "@alchemy/aa-core";
import { http } from "viem";
import { provider } from "./ethers-provider.js";
const eoaSigner: SmartAccountSigner =
LocalAccountSigner.mnemonicToAccountSigner(process.env.YOUR_OWNER_MNEMONIC!);
const chain = polygonMumbai;
// 2. Connect the provider to the smart account signer
export const accountSigner = provider.connectToAccount(
await createLightAccount({
chain,
transport: http("RPC_URL"),
signer: eoaSigner,
})
);
Returns
Promise<TransactionResponse>
A Promise
containing the ethers.js TransactionResponse
object
Parameters
transaction: Deferrable<TransactionRequest>
The ethers.js TransactionRequest
object, where each field may be a Promise or its value
overrides?:
UserOperationOverrides
Optional parameter where you can specify override values for maxFeePerGas
, maxPriorityFeePerGas
, callGasLimit
, preVerificationGas
, verificationGasLimit
or paymasterAndData
on the user operation request