This is a (hopefully) easy to use example of how you can use Hybrid Compute with Account Abstraction to build powerful Web3 Apps!
You can run this repo in 2 ways:
- On our official testnet "Boba Sepolia"
- or spin up the local stack end-to-end (including the local chain, the bundler for Account Abstraction, the snap, etc.)
Clone this repo with git clone --recurse-submodules -j8 [email protected]:bobanetwork/aa-hc-text2call.git
You will need a handful of tools to run the full stack (local):
cargo
[Download]forge
[Download]npm
|yarn
orpnpm
[Download]golang
[Download]Metamask Flask
(Development build of Metamask) [Download]
To run the stack on Boba Sepolia you can skip cargo
and golang
which is only required to run the local stack.
All contracts and services are deployed and environment variables are substituted across all services automatically to ensure a convenient developer experience.
- Make sure you have the dependencies as outlined above installed and Docker running.
- Run
pnpm start:local
to spin the local stack up. Make sure you have Docker running. - Head over to localhost:8001 to create your Smart Wallet.
- Once you created your account, try it out by using the "Transfer Funds" section. Make sure you funded your new "Snap Account" with some
ETH
on Boba Sepolia. - Congrats you sent your first
UserOp
on your local devnet using Account Abstraction! This is the moment your smart account gets deployed on-chain (on the first UserOp). - Navigate now to localhost:8000 to interact with your local DApp which utilizes Hybrid Compute via Account Abstraction to fetch off-chain data to your smart contract! In our example we fetch the current price of a cryptocurrency asset.
Please note, that the local stack actually spins up the Boba L2 locally, the Bundler ("Rundler") along with other local services. This might take a while to startup.
- Copy
/contracts/.env-example
and name it.env
. All necessary variables are pre-filled except ofPRIVATE_KEY
. - Add your own private key, that contains some ETH on Boba Sepolia in order to deploy the contracts on testnet. You can obtain some SepETH on Sepolia (L1) from any faucet and bridge them to L2 through our Gateway.
- Run
pnpm start:sepolia
to spin up the reduced local stack to use the existing infrastructure on Boba Sepolia. - Head over to hc-wallet.sepolia.boba.network to create your Smart Wallet.
- Once you created your account, try it out by using the "Transfer Funds" section. Make sure you funded your new "Snap Account" with some
ETH
on Boba Sepolia. - Congrats you sent your first
UserOp
on Boba Sepolia using Account Abstraction! If you navigate to the Block-Explorer you should see your contract wallet. - Navigate now to localhost:8000 to interact with your local DApp which utilizes Hybrid Compute via Account Abstraction to fetch off-chain data to your smart contract! In our example we fetch the current price of a cryptocurrency asset.
When you follow the steps above your application will use the already deployed backend below for simplification. If you want to deploy your own backend instead follow these steps:
- Deploy the backend to your cloud of your choosing [here is more documentation on that]. We've provided you with a Dockerfile and Docker Compose to make this as easy as possible.
- Once your backend is live, change the
BACKEND_URL
in your .env (if the file doesn't exist, you skipped the steps above) within yourcontracts folder
. - Rerun the script
pnpm start:sepolia
and try it out as described above.
Name | Address | Explainer |
---|---|---|
BACKEND | https://aa-hc-text2call.onrender.com/hc | |
FRONTEND | https://aa-hc-text2call-zbk5.onrender.com | |
HC_HELPER_ADDR | 0x1c64EC0A5E2C58295c3208a63209A2A719dF68D8 | HC Helper is system-wide available |
TOKEN_PRICE_ADDR | 0xcad49c0381c1B0779A318c2326Db43A6073adC1e | |
RPC_URL | https://gateway.tenderly.co/public/boba-sepolia | |
-> More RPC URls | https://chainlist.org/chain/28882 |
This is what a successful transaction will look like: 0x30056b3ff720f4d824422bd077b88c4333e86fbe5522bcdba96cfc8fa2a69b52
- transfer 0.001 eth to alice.eth
- transfer 10 usd worth of eth to bob.eth
- if the sun is shining in California, transfer 0.001 eth to alice.eth
This example utilizes Hybrid Compute 2.0 based on Account Abstraction.
Here is a high level overview of what happens:
The actual API call happens when the gas estimation happens (click for full page view):
If the gas estimation was successful, then we can submit our user operation (click for full page view):
Whenever you make changes and push to main
on your Github repository relevant tests are being run by Github actions to make sure everything works as expected.
If you want to run tests locally, execute pnpm test
.