{"id":51283414,"url":"https://github.com/onflow/flow-actions-scaffold","last_synced_at":"2026-06-30T03:30:35.960Z","repository":{"id":353210283,"uuid":"1034573306","full_name":"onflow/flow-actions-scaffold","owner":"onflow","description":"Starter scaffold for Flow Actions on the Flow network. Composable DeFi primitives (Sources, Sinks, Swappers) atomic in one Cadence transaction.","archived":false,"fork":false,"pushed_at":"2026-04-23T20:55:24.000Z","size":1383,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-03T23:41:47.083Z","etag":null,"topics":["automation","cadence","composable-defi","defi","flow","flow-actions","forte","scaffold","smart-contracts","sources-sinks-swappers","starter-template","web3"],"latest_commit_sha":null,"homepage":"https://developers.flow.com/","language":"Cadence","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-08T15:57:23.000Z","updated_at":"2026-04-23T20:55:28.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/onflow/flow-actions-scaffold","commit_stats":null,"previous_names":["onflow/flow-actions-scaffold"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/onflow/flow-actions-scaffold","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-actions-scaffold","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-actions-scaffold/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-actions-scaffold/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-actions-scaffold/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onflow","download_url":"https://codeload.github.com/onflow/flow-actions-scaffold/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onflow%2Fflow-actions-scaffold/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34951598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","cadence","composable-defi","defi","flow","flow-actions","forte","scaffold","smart-contracts","sources-sinks-swappers","starter-template","web3"],"created_at":"2026-06-30T03:30:34.353Z","updated_at":"2026-06-30T03:30:35.949Z","avatar_url":"https://github.com/onflow.png","language":"Cadence","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 👋 Welcome to the Flow Actions Scaffold\n\nThis repository is a scaffold for building with Flow Actions and includes AI-friendly guidance for composing safe Cadence transactions from standardized connectors.\n\n- **What's included**:\n  - Minimal Flow project with dependencies for Flow Actions and IncrementFi connectors\n  - Example transaction: Claim → Zap → Restake for IncrementFi LP rewards\n  - Cursor rules context for Flow Actions; helpful for agent-assisted development ([Cursor Rules](https://docs.cursor.com/en/context/rules))\n\nReferences:\n- FLIP-338: Flow Actions – composable standards for protocols ([FLIP PR #339](https://github.com/onflow/flips/pull/339))\n- FlowActions repo: [onflow/FlowActions](https://github.com/onflow/FlowActions)\n\n## 🔨 Prerequisites\n\n- Flow CLI: install from the [Flow CLI docs](https://developers.flow.com/tools/flow-cli/install)\n- Cursor + Cadence extension (recommended): [Cadence Extension](https://marketplace.visualstudio.com/items?itemName=onflow.cadence)\n\n## ⚡ Quick Commands (Makefile)\n\n```bash\nmake start      # Start emulator with full Increment Fi environment\nmake emulator   # Alias for 'make start' \nmake deploy     # Deploy contracts to network (NETWORK=emulator|testnet|mainnet)\nmake test       # Run Cadence tests\n\n# Example: Check rewards after setup\nflow scripts execute cadence/scripts/get_available_rewards.cdc --network emulator \\\n  --args-json '[{\"type\":\"Address\",\"value\":\"0xf8d6e0586b0a20c7\"},{\"type\":\"UInt64\",\"value\":\"0\"}]'\n```\n\n## 📦 Project Structure\n\n```\nflow-actions-scaffold/\n├── flow.json                              # Project configuration with FlowActions/IncrementFi dependencies\n├── README.md                              # This file\n└── cadence/\n    ├── contracts/                         # 🔌 Connector Contracts\n    │   └── ExampleConnectors.cdc          # Example TokenSink connector implementation\n    ├── scripts/                           # 📖 Read-Only Scripts\n    │   └── get_available_rewards.cdc      # Query claimable rewards from IncrementFi pools\n    ├── transactions/                      # 💸 Transaction Templates\n    │   └── increment_fi_restake.cdc       # Claim + Zap + Restake IncrementFi rewards\n    └── tests/                             # 🧪 Test Files\n        └── (test files as needed)\n```\n\n### 🔌 **Available Connectors**\n- **`ExampleConnectors.TokenSink`** - Simple sink that deposits tokens into a vault capability\n  - Demonstrates DeFiActions.Sink interface implementation\n  - Type-safe deposits with precondition checks\n  - UniqueIdentifier support for operation tracing\n\n### 📖 **Available Scripts**\n- **`get_available_rewards.cdc`** - Query claimable rewards from IncrementFi staking pools\n  - **Inputs**: `staker: Address, pid: UInt64`\n  - **Output**: `UFix64` - Amount of rewards available to claim\n  - Uses `PoolRewardsSource.minimumAvailable()` for accurate reward calculation\n\n### 💸 **Available Transactions**\n- **`increment_fi_restake.cdc`** - Complete restaking workflow for IncrementFi pools\n  - **Input**: `pid: UInt64` - Pool ID to restake rewards for\n  - **Flow**: Claim rewards → Zap to LP tokens → Restake into same pool\n  - **Safety**: Pre/post conditions, residual assertions, capacity-based withdrawals\n  - **Components**: Uses `PoolRewardsSource`, `Zapper`, `SwapSource`, and `PoolSink`\n\n## ⚙️ Setup \u0026 Account Configuration\n\n### 1. Install Dependencies (Required for All Networks)\n\nInstall all declared dependencies from `flow.json` right after cloning locally:\n```bash\ngit clone \u003cREPO_URL\u003e\ncd flow-actions-scaffold\nflow deps install\n```\nSee the Flow CLI Dependency Manager docs for details: [Dependency Manager](https://developers.flow.com/tools/flow-cli/dependency-manager).\n\n### 2. Account Setup by Network\n\n#### **Emulator (Local Development)**\nThe `make start` command handles all setup automatically using the built-in emulator service account, so no manual configuration is needed.\n\n#### **Testnet**\n1. Create an account:\n   ```bash\n   flow accounts create --network testnet\n   ```\n   This automatically updates your `flow.json` with the new account details.\n\n2. Fund it via the Testnet Faucet: [testnet-faucet.onflow.org](https://testnet-faucet.onflow.org)\n\n3. Create your `Staking.UserCertificate`: https://run.dnz.dev/snippet/12d94bff356ed607\n\n#### **Mainnet**\n1. **⚠️ Warning**: Transactions on mainnet incur fees and affect on-chain balances. Consider creating a new Flow Wallet account with limited funds.\n\n2. Create or configure your account:\n   - **Option A**: Create new account: `flow accounts create --network mainnet`\n   - **Option B**: Use existing account from Flow Wallet Extension ([Export private key guide](https://docs.wallet.flow.com/tutorial/extension-private-key-and-seed-phrase-guide))\n\n3. Ensure sufficient FLOW for fees and storage\n\n4. Create your `Staking.UserCertificate`: https://run.dnz.dev/snippet/d1bf715483551879\n\n5. **Set up IncrementFi position**: Go to `https://app.increment.fi` and stake tokens so you have an active position to restake rewards from.\n\n#### **Manual flow.json Configuration (if needed)**\nIf you prefer manual configuration, add accounts to the `accounts` section in `flow.json`:\n```json\n{\n  \"accounts\": {\n    \"my-testnet-account\": {\n      \"address\": \"0x1234567890abcdef\", \n      \"key\": { \"type\": \"file\", \"location\": \"my-testnet-account.pkey\" }\n    },\n    \"my-mainnet-account\": {\n      \"address\": \"0xabcdef1234567890\",\n      \"key\": { \"type\": \"file\", \"location\": \"my-mainnet-account.pkey\" }\n    }\n  }\n}\n```\nMake sure your private key files (`.pkey`) are in the project root and match the `location` specified.\n\n### 3. Find Your Pool ID (Testnet/Mainnet)\n- Go to the IncrementFi Farms page: https://app.increment.fi/farm\n- Locate your pool and read the number in the pool name (formatted like `#198`). That number is the `pid` used by scripts and transactions.\n\n![Find Pool ID](docs/assets/find_pool_id.png)\n\n## 🚀 Getting Started by Network\n\n### **Emulator (Recommended for Testing)**\n\n**🚀 Automated Setup (Recommended)**\n\n1. **Start the complete Increment Fi environment**:\n   ```bash\n   make start\n   ```\n   This automatically:\n   - Starts the Flow emulator and deploys Increment Fi dependencies\n   - Creates test tokens: **TokenA** and **TokenB** (1M each)\n   - Sets up liquidity pool: **TokenA-TokenB** pair (100k each token)\n   - Creates staking pool #0 with 50k pre-staked LP tokens\n   - Displays environment summary\n\n2. **Test the restake workflow**:\n   ```bash\n   # Check available rewards\n   flow scripts execute cadence/scripts/get_available_rewards.cdc \\\n     --network emulator \\\n     --args-json '[{\"type\":\"Address\",\"value\":\"0xf8d6e0586b0a20c7\"},{\"type\":\"UInt64\",\"value\":\"0\"}]'\n\n   # Run the restake transaction\n   flow transactions send cadence/transactions/increment_fi_restake.cdc \\\n     --signer emulator-account \\\n     --network emulator \\\n     --args-json '[{\"type\":\"UInt64\",\"value\":\"0\"}]'\n\n   # Verify rewards were claimed and restaked\n   flow scripts execute cadence/scripts/get_available_rewards.cdc \\\n     --network emulator \\\n     --args-json '[{\"type\":\"Address\",\"value\":\"0xf8d6e0586b0a20c7\"},{\"type\":\"UInt64\",\"value\":\"0\"}]'\n   ```\n\n**Why Pool ID `0`?** The automated setup creates the first staking pool with ID `0` containing your staked LP tokens and active rewards.\n\n### **Testnet/Mainnet**\n\nAfter completing account setup above, run the transaction:\n\n```bash\n# Testnet\nflow transactions send cadence/transactions/increment_fi_restake.cdc \\\n  --network testnet \\\n  --signer testnet-account \\\n  --args-json '[{\"type\":\"UInt64\",\"value\":\"\u003cYOUR_POOL_PID\u003e\"}]'\n\n# Mainnet  \nflow transactions send cadence/transactions/increment_fi_restake.cdc \\\n  --network mainnet \\\n  --signer mainnet-account \\\n  --args-json '[{\"type\":\"UInt64\",\"value\":\"\u003cYOUR_POOL_PID\u003e\"}]'\n```\n\nReplace `\u003cYOUR_POOL_PID\u003e` with your actual pool ID from the IncrementFi Farms page.\n\n## 🔧 Deployment Notes\n\n- **Emulator**: Contracts are deployed locally when you run `flow project deploy --network emulator`\n- **Testnet/Mainnet**: Connectors are already deployed and referenced via `dependencies.aliases` in `flow.json`\n\n## 🧭 Flow Actions Composition (Quick Reference)\n\nMinimal restake flow connectors used in `cadence/transactions/increment_fi_restake.cdc`: \n- Source: `IncrementFiStakingConnectors.PoolRewardsSource`\n- Swapper: `IncrementFiPoolLiquidityConnectors.Zapper` (token types and `stableMode` from pair)\n- SwapSource: `SwapConnectors.SwapSource(swapper, source)`\n- Sink: `IncrementFiStakingConnectors.PoolSink`\n\nString-based imports are used throughout. Safety invariants: size withdraws by sink capacity, assert residuals, single-expression pre/post.\n\n## 💬 Example AI Prompts\n- \"Create me a Cadence transaction which restakes my Increment Fi LP token staking rewards\"\n- \"Generate a minimal restake transaction using Flow Actions connectors (PoolRewardsSource → Zapper via SwapSource → PoolSink) with string imports and safety invariants\"\n- \"Compose a SwapSource from PoolRewardsSource and IncrementFiPoolLiquidityConnectors.Zapper, then stake to IncrementFiStakingConnectors.PoolSink with pre/post checks and residual assertion\"\n- \"Add a post condition verifying the stake increased by the expected zapper.quoteOut amount\"\n\n## 🧪 Testing\n\nRun Cadence tests:\n```bash\nmake test\n# or directly:\nflow test\n```\n\n## 🔗 Helpful Links\n\n- Flow Docs: [developers.flow.com](https://developers.flow.com)\n- Cadence Language: [cadence-lang.org/docs/language](https://cadence-lang.org/docs/language)\n- Block Explorers: [Flowscan](https://flowscan.io/)\n\n## 🤝 Community\n- Forum: [forum.flow.com](https://forum.flow.com/)\n- Discord: [discord.gg/flow](https://discord.gg/flow)\n- Telegram: [Flow Blockchain - Official](https://t.me/flow_blockchain)\n- X: [@flow_blockchain](https://x.com/flow_blockchain)\n## About Flow\n\nThis repo is part of the [Flow network](https://flow.com), a Layer 1 blockchain built for consumer applications, AI agents, and DeFi at scale.\n\n- Developer docs: https://developers.flow.com\n- Cadence language: https://cadence-lang.org\n- Community: [Flow Discord](https://discord.gg/flow) · [Flow Forum](https://forum.flow.com)\n- Governance: [Flow Improvement Proposals](https://github.com/onflow/flips)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonflow%2Fflow-actions-scaffold","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonflow%2Fflow-actions-scaffold","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonflow%2Fflow-actions-scaffold/lists"}