Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openfort-xyz/openfort-fc-frames-demo
https://github.com/openfort-xyz/openfort-fc-frames-demo
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/openfort-xyz/openfort-fc-frames-demo
- Owner: openfort-xyz
- Created: 2024-02-13T00:40:19.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-14T11:44:41.000Z (10 months ago)
- Last Synced: 2024-08-03T18:10:39.271Z (4 months ago)
- Language: Solidity
- Homepage: https://openfort-frames-demo.onrender.com
- Size: 6.13 MB
- Stars: 5
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-frames - Account Abstraction + Meta-transactions Frame
README
# Openfort x Frames Demo
This is an example [Farcaster](https://www.farcaster.xyz/) [**Frame**](https://docs.farcaster.xyz/learn/what-is-farcaster/frames) to demonstrate how you can use Frames alongside Openfort's [**accounts**](https://www.openfort.xyz/docs/guides/accounts) feature to create novel experiences for your users.
When a user first sees this demo Frame in their Farcaster client, they can click a button to redeem a testnet NFT. Behind the scenes, Openfort creates an smart wallet with the current Farcaster user and airdrops an NFT to it. Users can view their NFT by visiting any explorerwith their new smart account address. This is a **testnet NFT** on the Base Sepolia testnet.
This app is built with [ExpressJs](https://expressjs.com/), and makes uses of libraries like [`@coinbase/onchainkit`](https://github.com/coinbase/onchainkit), [`@farcaster/hub-node-js`](https://github.com/farcasterxyz/hub-monorepo/tree/main/packages/hub-nodejs), and [`viem`](https://viem.sh/) for interacting with the blockchain and the [Farcaster](https://www.farcaster.xyz/) protocol.
## Live Demo
To see this demo in action, share [`https://openfort-frames-demo.onrender.com`](https://openfort-frames-demo.onrender.com) in any Farcaster client that supports Frames (e.g. Warpcast) and interact with it. You can then go to any explorer with your new address to view your NFT.
## Setup
1. Fork this repository, clone it, and open it in your command line:
```sh
git clone https://github.com//openfort-frames-demo
```2. Install the necessary dependencies using your preferred package manager:
```sh
npm i
```3. Using a fresh development wallet, deploy an ERC-721 contract at to the Base Sepolia testnet. **Do not use a real wallet, as you must store the development wallet's seed phrase as an environment secret.** You can use a tool like [Remix](https://remix.ethereum.org/) or [`hardhat`](https://www.npmjs.com/package/hardhat) to deploy your contract.
4. Initialize your environment variables by copying the contents of `.env.example` to a new `.env` file, and fill in the required values. You'll need to set a base URL, your contract ID, policy ID, developer account ID, and your Openfort API key.
5. Import the contract: Checkout the [guide](https://www.openfort.xyz/docs/guides/transaction-cloud/policies/strategies).
6. Create a Policy to sponsor the transactions: Checkout the [guide](https://www.openfort.xyz/docs/guides/transaction-cloud/policies/strategies). For this demo, you must include two policy rules. One of type 'account_functions' to allow for smart contract deployment, and another rule of type 'contract_functions' to allow sponsoring the mint gaslessly.
7. Creating a Developer Account to mint the assets: Checkout the [guide](https://www.openfort.xyz/docs/guides/accounts/dev/minting-account).
```sh
NEXT_PUBLIC_BASE_URL=
CONTRACT_ID=
POLICY_ID=
DEVELOPER_ACCOUNT_ID=
OPENFORT_API_KEY=
```**That's it!** To run the demo locally, execute `npm run dev` and open [http://localhost:3000](http://localhost:3000).
## Testing the frame
You can test this Frame using [Warpcast Embed Tools](https://warpcast.com/~/developers/frames) to preview the frame interaction. Please note that a `localhost` URL will not work with Warpcast Embed Tools, so you should set up a public tunnel to your local app using a tool like [`ngrok`](https://ngrok.com/) or [Cloudflare](https://www.cloudflare.com/products/tunnel/).
## Check out
- `src/lib/smart-wallet.ts` to see how to use Openfort to pre-generate smart wallets for a user's Farcaster accounts
- `src/lib/farcaster.ts` to see how Frames are generated and how to verify a user's Farcaster account and query the protocol for their Farcaster data
- `src/lib/nft.ts` to see how to airdrop the ERC-721 you deployed to a user's wallet address
- `src/services/wallet.ts` to see how the first Frame interaction generates an embedded wallet for the user
- `src/services/mint.ts` to see how the second Frame interaction airdrops an NFT to the user
- `contracts/src/OpenfortFrameNFT.sol` for the sample contract used.