https://github.com/shivamycodee/vice-aa
made account abstraction easy to understand and use.
https://github.com/shivamycodee/vice-aa
account-abstraction erc4337 erc4337-supported-blockexplorer polygon-mumbai polygon-network
Last synced: 3 months ago
JSON representation
made account abstraction easy to understand and use.
- Host: GitHub
- URL: https://github.com/shivamycodee/vice-aa
- Owner: Shivamycodee
- Created: 2023-12-29T13:59:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-23T18:48:10.000Z (5 months ago)
- Last Synced: 2025-03-14T10:39:20.938Z (4 months ago)
- Topics: account-abstraction, erc4337, erc4337-supported-blockexplorer, polygon-mumbai, polygon-network
- Language: JavaScript
- Homepage: https://npmjs.com/package/vice-aa
- Size: 34.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Installation
```javascript
npm install vice-aa
```## Supported Networks
- [AMOY NETWORK](https://amoy.polygonscan.com/)
- [MUMBAI NETWORK](https://mumbai.polygonscan.com/) (Depreciated.)
- [POLYGON NETWORK](https://polygonscan.com/) (Comming Soon...)
## Paymaster URL'sSimple Paymaster -> https://vice-aa-api.vercel.app/paymaster
ERC20 Token Paymaster -> https://vice-aa-api.vercel.app/tokenpaymaster
# ERC20 Token For TokenPaymaster
- Token Name: HYPER TOKEN
- Token Address: [0x5c54b57557BAB28aC1C416063f657d8C89842896](https://amoy.polygonscan.com/token/0x5c54b57557BAB28aC1C416063f657d8C89842896)You can get this token from [Uniswap](https://app.uniswap.org/swap)
> ⚠️ **WARNING:** MAKE SURE TO APPROVE THE [ERC20PAYMASTER](https://amoy.polygonscan.com/address/0x22bE1dca416b40dc67F1fD09Eaa49347E5b34720) CONTRACT FOR HYPER TOKEN TO USE ERC20PAYMASTER URL.
## Usage
This package provides four main functions:
- `getUserOperation`
- `getSignedUserOp`
- `CustomJsonRpcProvider`
- `waitForReceipt`Follow the steps below to use these functions in your project.
### Step 1: Create a Provider and Contract Instance
First, set up your provider and create an instance of the contract with which you wish to interact.
```javascript
import { ethers } from "ethers";
import { YourContractAddress, YourContractABI } from "";const provider = new ethers.providers.Web3Provider(window.ethereum);
const contract = new ethers.Contract(YourContractAddress, YourContractABI, provider);
```## Step 2: Populate Your Transaction
Next, populate the transaction you intend to execute.
```javascript
const populatedTx = await contract.populateTransaction.(
// Method parameters go here
);
```## Step 3: Get User Operation
Use getUserOperation with your contract wallet address, contract address, populated transaction, paymaster URL, and your chosen RPC URL.
```javascript
import { getUserOperation } from "vice-aa";const userOperation = await getUserOperation(
yourContractWalletAddress,
YourContractAddress,
populatedTx,
"https://",
""
);
```## Step 4: Get Signed User Operation
Then, call getSignedUserOp with the userOperation , paymaster URL, and a boolean to indicate the type of paymaster.
```javascript
import { getSignedUserOp } from "vice-aa";const signedUserOp = await getSignedUserOp(
userOperation,
"https://",
true // Set to false for ERC20 paymaster
);
```## Step 5: Send User Operation
Create a custom provider and send the user operation.
```javascript
import { CustomJsonRpcProvider } from "vice-aa";const customProvider = new CustomJsonRpcProvider("");
const userOpHash = await customProvider.sendUserOperation(signedUserOp);
```## Step 6: Wait for Transaction Receipt
Finally, wait for the transaction hash using waitForReceipt.
```javascript
import { waitForReceipt } from "vice-aa";
const txHash = await waitForReceipt(customProvider, userOpHash);
```## Example
- [Apporve A Contract for Token Transfer](https://gist.github.com/Shivamycodee/ea3364cf816863c62cdeb9e6d0b556d0)
## Support
For additional support or queries, feel free to reach out or open an issue on the [vice-aa repository](https://github.com/Shivamycodee/vice-aa).