{"id":19163198,"url":"https://github.com/programmer-ke/eth-decentralized-staking-app","last_synced_at":"2025-02-22T22:42:36.753Z","repository":{"id":196451597,"uuid":"696136799","full_name":"programmer-ke/eth-decentralized-staking-app","owner":"programmer-ke","description":"s","archived":false,"fork":false,"pushed_at":"2023-12-16T12:57:32.000Z","size":1631,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"challenge-1-decentralized-staking","last_synced_at":"2025-01-03T21:43:18.511Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/programmer-ke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2023-09-25T06:54:50.000Z","updated_at":"2023-09-25T06:57:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e1ebc59-68e7-4c05-9a1b-0d9da21b4f22","html_url":"https://github.com/programmer-ke/eth-decentralized-staking-app","commit_stats":null,"previous_names":["programmer-ke/eth-decentralized-staking-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmer-ke%2Feth-decentralized-staking-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmer-ke%2Feth-decentralized-staking-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmer-ke%2Feth-decentralized-staking-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programmer-ke%2Feth-decentralized-staking-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/programmer-ke","download_url":"https://codeload.github.com/programmer-ke/eth-decentralized-staking-app/tar.gz/refs/heads/challenge-1-decentralized-staking","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240245887,"owners_count":19771029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-09T09:14:27.862Z","updated_at":"2025-02-22T22:42:36.727Z","avatar_url":"https://github.com/programmer-ke.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚩 🥩 Decentralized Staking App v2 - simpler state logic\n\nThis takes the Decentralized Stacking challenge that is part of the\nspeedrun and simplifies the state transition logic.\n\nInstead of having state logic spread across multiple modifiers and\nstate variables, we use a single state variable to track the current\nstate and execute transition logic based on its value.\n\nWe define three states for the Staker: `Opened`, `Completed` \u0026\n`OpenForWithdrawals`.\n\nThis state will be manipulated by the event handling logic for each\nof the three events: `stake`, `execute` and `withdraw`.\n\nThis results in easier to reason about logic that is less error prone.\n\nNB: For local dev, we need to generate blocks manually in some cases.\nTriggering the `generateBlocks` method from the Debug Contract tab\nwill help with this.\n\nThe rest of the description follows.\n\n![readme-1](https://github.com/scaffold-eth/se-2-challenges/assets/80153681/a620999a-a1ff-462d-9ae3-5b49ab0e023a)\n\n🦸 A superpower of Ethereum is allowing you, the builder, to create a\nsimple set of rules that an adversarial group of players can use to\nwork together. In this challenge, you create a decentralized\napplication where users can coordinate a group funding effort. If the\nusers cooperate, the money is collected in a second smart contract. If\nthey defect, the worst that can happen is everyone gets their money\nback. The users only have to trust the code.\n\n🏦 Build a `Staker.sol` contract that collects **ETH** from numerous\naddresses using a payable `stake()` function and keeps track of\n`balances`. After some `deadline` if it has at least some `threshold`\nof ETH, it sends it to an `ExampleExternalContract` and triggers the\n`complete()` action sending the full balance. If not enough **ETH** is\ncollected, allow users to `withdraw()`.\n\n🎛 Building the frontend to display the information and UI is just as\nimportant as writing the contract. The goal is to deploy the contract\nand the app to allow anyone to stake using your app. Use a\n`Stake(address,uint256)` event to list all stakes.\n\n🌟 The final deliverable is deploying a Dapp that lets users send\nether to a contract and stake if the conditions are met, then `yarn\nvercel` your app to a public webserver. Submit the url on\n[SpeedRunEthereum.com](https://speedrunethereum.com)!\n\n### ⚠️ Test it!\n\n- Run `yarn test` to run the automated testing function. It will test\n  that you hit the core checkpoints. You are looking for all green\n  checkmarks and passing tests!\n\n---\n\n##  💾 Deploy your contract! 🛰\n\n📡 Edit the `defaultNetwork` to [your choice of public EVM networks](https://ethereum.org/en/developers/docs/networks/) in `packages/hardhat/hardhat.config.ts`\n\n🔐 You will need to generate a **deployer address** using `yarn generate` This creates a mnemonic and saves it locally.\n\n👩‍🚀 Use `yarn account` to view your deployer account balances.\n\n⛽️ You will need to send ETH to your deployer address with your wallet, or get it from a public faucet of your chosen network.\n\n\u003e 📝 If you plan on submitting this challenge, be sure to set your `deadline` to at least `block.timestamp + 72 hours`\n\n🚀 Run `yarn deploy` to deploy your smart contract to a public network (selected in `hardhat.config.ts`)\n\n\u003e 💬 Hint: You can set the `defaultNetwork` in `hardhat.config.ts` to `sepolia` **OR** you can `yarn deploy --network sepolia`.\n\n![allStakings-blockFrom](https://github.com/scaffold-eth/se-2-challenges/assets/55535804/04725dc8-4a8d-4089-ba82-90f9b94bfbda)\n\n\u003e 💬 Hint: For faster loading of your _\"Stake Events\"_ page, consider updating the `fromBlock` passed to `useScaffoldEventHistory` in [`packages/nextjs/pages/stakings.tsx`](https://github.com/scaffold-eth/se-2-challenges/blob/challenge-1-decentralized-staking/packages/nextjs/pages/stakings.tsx) to `blocknumber - 10` at which your contract was deployed. Example: `fromBlock: 3750241n` (where `n` represents its a [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)). To find this blocknumber, search your contract's address on Etherscan and find the `Contract Creation` transaction line.\n\n---\n\n## 🚢 Ship your frontend! 🚁\n\n✏️ Edit your frontend config in `packages/nextjs/scaffold.config.ts` to change the `targetNetwork` to `chains.sepolia` or any other public network.\n\n💻 View your frontend at http://localhost:3000/stakerUI and verify you see the correct network.\n\n📡 When you are ready to ship the frontend app...\n\n📦 Run `yarn vercel` to package up your frontend and deploy.\n\n\u003e Follow the steps to deploy to Vercel. Once you log in (email, github, etc), the default options should work. It'll give you a public URL.\n\n\u003e If you want to redeploy to the same production URL you can run `yarn vercel --prod`. If you omit the `--prod` flag it will deploy it to a preview/test URL.\n\n\u003e 🦊 Since we have deployed to a public testnet, you will now need to connect using a wallet you own or use a burner wallet. By default 🔥 `burner wallets` are only available on `hardhat` . You can enable them on every chain by setting `onlyLocalBurnerWallet: false` in your frontend config (`scaffold.config.ts` in `packages/nextjs/`)\n\n#### Configuration of Third-Party Services for Production-Grade Apps.\n\nBy default, 🏗 Scaffold-ETH 2 provides predefined API keys for popular services such as Alchemy and Etherscan. This allows you to begin developing and testing your applications more easily, avoiding the need to register for these services.  \nThis is great to complete your **SpeedRunEthereum**.\n\nFor production-grade applications, it's recommended to obtain your own API keys (to prevent rate limiting issues). You can configure these at:\n\n- 🔷`ALCHEMY_API_KEY` variable in `packages/hardhat/.env` and `packages/nextjs/.env.local`. You can create API keys from the [Alchemy dashboard](https://dashboard.alchemy.com/).\n\n- 📃`ETHERSCAN_API_KEY` variable in `packages/hardhat/.env` with your generated API key. You can get your key [here](https://etherscan.io/myapikey).\n\n\u003e 💬 Hint: It's recommended to store env's for nextjs in Vercel/system env config for live apps and use .env.local for local testing.\n\n---\n\n## 📜 Contract Verification\n\nRun the `yarn verify --network your_network` command to verify your contracts on etherscan 🛰\n\n---\n\n\u003e 🏃 Head to your next challenge [here](https://speedrunethereum.com).\n\n\u003e 💬 Problems, questions, comments on the stack? Post them to the\n[🏗 scaffold-eth developers chat](https://t.me/joinchat/F7nCRK3kI93PoCOk)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrammer-ke%2Feth-decentralized-staking-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogrammer-ke%2Feth-decentralized-staking-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogrammer-ke%2Feth-decentralized-staking-app/lists"}