🧪 An open-source, up-to-date toolkit for building decentralized applications (dapps) on the Ethereum blockchain. It's designed to make it easier for developers to create and deploy smart contracts and build user interfaces that interact with those contracts.
⚙️ Built using NextJS, RainbowKit, Hardhat, Wagmi, and Typescript.
- ✅ Contract Hot Reload: Your frontend auto-adapts to your smart contract as you edit it.
- 🔥 Burner Wallet & Local Faucet: Quickly test your application with a burner wallet and local faucet.
- 🔐 Integration with Wallet Providers: Connect to different wallet providers and interact with the Ethereum network.
Before you begin, you need to install the following tools:
- Node (v18 LTS)
- Yarn (v1 or v2+)
- Git
To get started follow the steps below:
- Clone this repo & install dependencies
cd scaffold-eth-2
yarn install
- Run a local network in the first terminal:
yarn chain
This command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in hardhat.config.ts
.
- On a second terminal, deploy the test contract:
yarn deploy
This command deploys a test smart contract to the local network. The contract is located in packages/hardhat/contracts
and can be modified to suit your needs. The yarn deploy
command uses the deploy script located in packages/hardhat/deploy
to deploy the contract to the network. You can also customize the deploy script.
- On a third terminal, start your NextJS app:
yarn start
Visit your app on: http://localhost:3000
. You can interact with your smart contract using the contract component or the example ui in the frontend. You can tweak the app config in packages/nextjs/scaffold.config.ts
.
Run smart contract test with yarn hardhat:test
- Edit your smart contract
YourContract.sol
inpackages/hardhat/contracts
- Edit your frontend in
packages/nextjs/pages
- Edit your deployment scripts in
packages/hardhat/deploy
Visit our docs to learn how to start building with Scaffold-ETH 2.
To know more about its features, check out our website.
We welcome contributions to Scaffold-ETH 2!
Please see CONTRIBUTING.MD for more information and guidelines for contributing to Scaffold-ETH 2.
PactStatus
: { Inactive, Active, Completed }
onlyContributor()
: Ensure only a contributor can call the associated function.onlyOwner()
: Ensure only the owner can call the associated function.onlyPrivileged()
: Ensure only a privileged address can call the associated function.
-
Participant
:participantAddress
: Address of the participant.isEligible
: A boolean to check if the participant is eligible.canClaim
: A boolean to check if the participant can claim.
-
Pact
:title
: Title of the pact.description
: Description of the pact.numberOfParticipants
: Number of participants in the pact.duration
: Duration of the pact in seconds.startDate
: Timestamp when the pact starts.ante
: Deposit amount to join the pact.participants
: Array of participants.status
: Status of the pact (PactStatus
).lastCheckInTimestamp
: Mapping of addresses to their last check-in timestamps.
-
PactWithJoinable
:pact
: Pact.isJoinable
: A boolean to check if the pact is joinable.
owner
: Address of the contract owner.numContributors
: Number of contributors.totalBalance
: Total balance of the contract.endTime
: End time for the contract.contributions
: Mapping of addresses to their contributions.pacts
: Array of pacts.privilegedAddresses
: Mapping of addresses to their privilege status (true if privileged, false otherwise).
-
AnteDeposited(address indexed user, uint256 amount, uint256 pactId)
: Emitted when an ante is deposited. -
ProofSubmitted(address indexed participantAddress, uint256 indexed pactIndex, string ipfsHash)
: Emitted when a proof is submitted.
-
createPact(string memory _title, string memory _description, uint256 _numberOfParticipants, uint256 _duration, uint256 _startDate, uint256 _ante) public payable returns(uint256)
- Example Input:
"Sample Pact", "This is a sample pact", 10, 864000, 1735700800, 5 ether
- Expected Return: Index of the created pact.
- Example Input:
-
joinPact(uint256 pactIndex) public payable
- Example Input:
3
(Assuming you want to join the pact at index 3). - Expected Return: None. State of the contract is updated.
- Example Input:
-
getPactDetails(uint256 pactIndex) public view returns (string memory title, string memory description, uint256 numberOfParticipants, uint256 activeParticipantsCount, uint256 duration, uint256 startDate, uint256 ante, PactStatus status, bool isJoinable)
- Example Input:
2
- Expected Return: Details of the pact at index 2 in the specified format.
- Example Input:
-
getParticipantAddress(uint256 pactIndex, uint256 participantIndex) public view returns (address)
- Example Input:
2, 5
- Expected Return: Address of the 6th participant in the 3rd pact.
- Example Input:
-
contribute() external payable
- Example Input: Transaction with
value = 2 ether
- Expected Return: None. State of the contract is updated.
- Example Input: Transaction with
-
withdraw() external onlyContributor
- Expected Return: None. State of the contract is updated, and contributor receives their balance.
-
updatePactStatus(uint256 pactIndex) public
- Example Input:
4
- Expected Return: None. State of the pact is updated.
- Example Input:
-
getPactStatus(uint256 pactIndex) public view returns (PactStatus)
- Example Input:
3
- Expected Return: Status of the pact at index 3 (
Inactive
,Active
, orCompleted
).
- Example Input:
-
getCurrentTimestamp() public view returns (uint256)
- Expected Return: Current timestamp.
-
getFulfillmentEstimate(uint256 pactIndex) public view returns (address[] memory, uint256[] memory)
- Example Input:
2
- Expected Return: Arrays of addresses of participants and their respective returns for the pact at index 2.
claimFulfillment(uint256 pactIndex) public
- Example Input:
3
- Expected Return: None. Eligible participant claims their share from the pact at index 3.
reclaimAnte(uint256 pactIndex) public
- Example Input:
5
- Expected Return: None. Participant reclaims their ante from the pact at index 5.
-
submitProof(uint256 pactIndex, string memory ipfsHash) public
- Description: Function for a participant to submit proof for a pact.
- Example Input:
3, "QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco"
- Expected Return: None. Proof is submitted for the pact at index 3 and an event is emitted.
-
submitProof(uint256 pactIndex, string memory ipfsHash) public
- Description: Function for a participant to submit proof for a pact.
- Example Input:
3, "QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco"
- Expected Return: None. Proof is submitted for the pact at index 3 and an event is emitted.
checkMissedCheckIn(uint256 pactIndex, address participant) external
- Description: Check if a participant has missed a check-in.
- Example Input:
4, 0x4b20993Bc481177ec7E8f571ceCaE8A9e22C02db
- Expected Return: None. If the participant missed the check-in, their eligibility for the pact rewards is revoked.
invalidateParticipant(uint256 pactIndex, address participant) external onlyPrivileged
- Description: Invalidate a participant from a pact, revoking their eligibility.
- Example Input:
5, 0x4b20993Bc481177ec7E8f571ceCaE8A9e22C02db
- Expected Return: None. The participant's eligibility for the pact rewards is revoked.
grantPrivilege(address _address) external onlyOwner
- Description: Grant privilege to an address, allowing them to invalidate participants.
- Example Input:
0x4b20993Bc481177ec7E8f571ceCaE8A9e22C02db
- Expected Return: None. The given address is granted privileges.
revokePrivilege(address _address) external onlyOwner
- Description: Revoke privilege from an address, removing their ability to invalidate participants.
- Example Input:
0x4b20993Bc481177ec7E8f571ceCaE8A9e22C02db
- Expected Return: None. The given address has its privileges revoked.