Skip to content

Commit 326bbb7

Browse files
committed
All main pages, add members, balances, favicon
1 parent 5866723 commit 326bbb7

18 files changed

+1697
-45
lines changed

.env.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PRIVATE_KEY=
2+
CHAIN_ID=80001

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ npm-debug.log*
3434

3535
cache
3636
artifacts
37+
38+
.env

contracts.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Signer as EthersSigner, providers } from "ethers";
2+
import { useContract, useContractRead } from "wagmi";
3+
4+
export type Signer = EthersSigner | providers.Provider | null | undefined;
5+
6+
function config(signer: Signer) {
7+
return {
8+
addressOrName: {
9+
80001: "0x5F20f3Ff685c66ABf2947F01f1cC55C99B1e40d9",
10+
}[process.env.CHAIN_ID || 80001]!,
11+
contractInterface: require("./artifacts/contracts/Split3.sol/Split3.json").abi,
12+
signerOrProvider: signer,
13+
};
14+
}
15+
16+
export function useSplitContract(signer: Signer) {
17+
return useContract(config(signer));
18+
}
19+
20+
export function useSplitContractRead(signer: Signer, functionName: string, args: any[]) {
21+
return useContractRead(config(signer), functionName, { args });
22+
}

contracts/Split3.sol

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ pragma solidity >=0.8.0 <0.9.0;
33

44
contract Split3 {
55
mapping(address => int) public balances;
6+
address[] public members;
7+
8+
function addMember(address member) public {
9+
members.push(member);
10+
}
11+
12+
function getMembers() public view returns (address[] memory) {
13+
return members;
14+
}
615

716
// Deposit into the contract to enable paying ahead on your debt. Also enables others to take loans
817
function deposit() public payable {
@@ -11,7 +20,7 @@ contract Split3 {
1120

1221
// Take loans, pay back with deposit()
1322
function withdraw(uint amount) public {
14-
require (amount <= address(this).balance, "Contract does not have enough funds to loan");
23+
require(amount <= address(this).balance, "Contract does not have enough funds to loan");
1524
balances[msg.sender] -= int(amount);
1625
(bool sent, ) = msg.sender.call{value: amount}("");
1726
require(sent, "Failed to send");

deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ethers } from "hardhat";
1+
import { ethers } from 'hardhat';
22

33
async function main() {
44
const Split3 = await ethers.getContractFactory("Split3");

hardhat.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
require("dotenv").config();
12
require("@nomiclabs/hardhat-waffle");
23

34
module.exports = {
45
solidity: "0.8.4",
6+
networks: {
7+
mumbai: {
8+
url: "https://rpc.valist.io/mumbai",
9+
accounts: [process.env.PRIVATE_KEY],
10+
},
11+
},
512
};

0 commit comments

Comments
 (0)