Skip to content

Instantly share code, notes, and snippets.

@Rahat-ch
Created January 13, 2024 17:35
Show Gist options
  • Select an option

  • Save Rahat-ch/e62dcf53cab1c5502f678c16ef43079e to your computer and use it in GitHub Desktop.

Select an option

Save Rahat-ch/e62dcf53cab1c5502f678c16ef43079e to your computer and use it in GitHub Desktop.
const handleDeposit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (smartAccount === null) return
const approvalTrx = tokenContract.populateTransaction.approve(
allowanceContract.address,
10
);
const depositTrx = allowanceContract.populateTransaction.deposit(10);
const userOp = await smartAccount.buildUserOp([approvalTrx, depositTrx]);
try {
const userOpResponse = await smartAccount.sendUserOp(userOp);
console.log("userOpHash", userOpResponse);
const { receipt } = await userOpResponse.wait();
console.log("txHash", receipt.transactionHash);
} catch (error) {
console.error(error);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment