This is a easy to use example of how you can use Hybrid Compute with Account Abstraction to build powerful Web3 Apps!
This "Hello World" example allows you to fetch the current price of any cryptocurrency from an off-chain API such as CoinRanking into your smart contract within 1 single, atomic transaction!
You can run this repo on our official testnet "Boba Sepolia"
- https://pricefeed-frontend.onrender.com/
- https://presibot.onrender.com/
- https://codecaster.onrender.com/
Clone this repo with git clone --recurse-submodules -j8 git@github.com:bobanetwork/aa-hc-example.git
Every AA-HC example consists of
Backend- must be deployed by yourself using the example in the
/backendfolder. This can happen before you start theInstallationpart. For the installation part it is necessary that you have a valid URL (https://) that will point to your backend. The URL must not work at deployment, so feel free to add your URL destination for now.
- must be deployed by yourself using the example in the
Custom Contract- The custom contract (as in this example, the TokenContract) stores the data from the HC call. Your Contract will be created by following the Installation Guide.
Hybrid Account- The Hybrid Account is responsible for communicating with the
HCHelperand callingTryCallOffchain. In the Installation setup, a HybridAccount for this example will be created.
- The Hybrid Account is responsible for communicating with the
Simple Account- The Simple Account is used to communicate with your AA-HC application. If your application should work in a browser, please create your Hybrid Account within the Boba Hub using the provided
Boba Snap. If you intend to create a console-only application, you may use the SDK and itsUserOperationManagerto create your accounts, send Ops or test your application: AA-HC-SDK.
- The Simple Account is used to communicate with your AA-HC application. If your application should work in a browser, please create your Hybrid Account within the Boba Hub using the provided
- Copy
/contracts/.env-exampleand name it.env. Please add the URL of your where your backend server will live. - 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:sepoliato spin up the reduced local stack to use the existing infrastructure on Boba Sepolia. - Head over to the Hub https://hub.boba.network/ to create your Smart Wallet or make use of the SDK to create your smart wallet on the console AA-HC-SDK
- Once you created your account, try it out by using the "Transfer Funds" section. Make sure you funded your new "Snap Account" with some
ETHon Boba Sepolia. - Congrats you sent your first
UserOpon 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.
| Name | Address | Explainer |
|---|---|---|
| BACKEND | https://pricefeed-backen.onrender.com | |
| FRONTEND | https://pricefeed-frontend.onrender.com/ | |
| HC_HELPER_ADDR | 0x11c4DbbaC4A0A47a7c76b5603bc219c5dAe752D6 | 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