This is a full-stack project that demonstrates how to build account abstraction dApps without using any convernience aa library. It features an ERC20 token and a user interface that allows users to interact with the token's features, such as minting, transferring, burning, and dispersing tokens, with the option of gas sponsorship.
This is a pnpm monorepo with the following structure:
contracts/: A Hardhat project for theSimpleAATokensmart contract.ui/: A Next.js project for the dApp's user interface.
Follow these steps to set up and run the project locally.
Clone the project to your local machine:
git clone https://github.com/AjayiMike/simple-aa-dapp.git
cd simple-aa-dappInstall all project dependencies from the root of the monorepo:
pnpm installFirst, we'll set up and deploy the SimpleAAToken smart contract.
-
Navigate to the
contractsdirectory and create a.envfile. -
Add the following variables to the
.envfile, replacing the placeholder values with your own:RPC_URL="YOUR_SEPOLIA_RPC_URL" PRIVATE_KEY="YOUR_PRIVATE_KEY" CHAIN_ID=11155111 ETHERSCAN_KEY="YOUR_ETHERSCAN_API_KEY"
-
Deploy to Sepolia Testnet:
From the root of the project, run:
pnpm contracts hardhat ignition deploy ignition/modules/SimpleAAToken.ts --network sepolia
After a successful deployment, take note of the deployed contract address. You will need it for the UI setup.
-
Verify on Etherscan:
pnpm contracts verify <token address>
Now, let's set up the user interface.
- Navigate to the
uidirectory and create a.envfile from the example file. - Add your environment variable values to the
.envfile. The required variables are:NEXT_PUBLIC_MAGIC_API_KEYNEXT_PUBLIC_CHAIN_IDNEXT_PUBLIC_RPC_URLNEXT_PUBLIC_PAYMASTER_URLNEXT_PUBLIC_BUNDLER_URLNEXT_PUBLIC_TOKEN_CONTRACT_ADDRESS(from the deployment step above)
-
Particle Network (
PAYMASTER_URL&BUNDLER_URL)- Go to the Particle Network Dashboard.
- Create a new project or select an existing one.
- Copy your project's Bundler and Paymaster URLs.
-
Magic Link (
MAGIC_API_KEY)- Go to the Magic Link Dashboard.
- Create a new project or select an existing one.
- From your project's dashboard, copy the "Publishable API Key".
- Make sure to set up Google Social Login for your project. The Magic Link dashboard and documentation provide detailed instructions on how to do this.
To start the Next.js development server for the UI, run the following command from the root of the project:
pnpm ui devOpen http://localhost:3000 in your browser to see the dApp in action.