Skip to content

Commit

Permalink
rename to fullstack web3 template
Browse files Browse the repository at this point in the history
  • Loading branch information
olivmath committed Sep 23, 2024
1 parent 03ca9d2 commit f1570aa
Show file tree
Hide file tree
Showing 58 changed files with 142 additions and 65 deletions.
79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
# Fullstack Web3 Template
# Fullstack Web3 Template v2.1.0

## QuickStart

**You need run 3 app, using 3 terminals**:

1. Frontend
2. Blockchain local (anvil)
3. Deploy your smartcontracts into blockchain

### Frontend

1. **Install frontend**

```bash
cd ui
npm install # or yarn or pnpm install
```

2. **Run application**

```bash
npm run dev # or yarn dev or pnpm dev
```

### Blockchain

```bash
anvil -b 1 # Mining blocks every 1 second
```

### Deploy your Smartcontracts

```bash
cd smartcontracts
./deploy.local.sh
```

## FWT Structure

```
├── smartcontracts/
│ ├── ...
│ ├── lib
│ ├── deploy-on-local.sh
│ ├── script
│ │ └── deploy.local.s.sol
│ ├── src
│ │ └── Counter.sol
│ └── test
│ ├── BaseSetup.t.sol
│ ├── Counter.t.sol
│ └── Utils.t.sol
└── ui/
├── ...
├── contracts
│ └── deployedContracts.ts
└── package.json
```

**Explain**:

- The **contracts** folder contains everything you need to build smartcontracts.
- The **ui** folder contains everything you need to interact with your smartcontract using frontend.

### `contracts` structure

- **`deploy-on-local.sh`**: just call it to deploy, it makes deployment simple without copying and pasting things.
- **`src/*`**: the folder where we will write our contracts.
- **`test/*`**: the folder where we will write our tests.
- **`lib/*`**: the folder where the foundry stores the libraries.
- **`script/deploy.local.s.sol`**: the solidity script responsible for actually doing the deployment.
- **`test/BaseSetup.t.sol`**: is the contract where we are going to configure the tests.

### `ui` structure

- **`contracts/deployedContracts.ts`**: ABI of the contract that will be ‘auto-magically’ copied by the `smartcontracts/deploy.py` script.
- **`package.json`**: list of dependencies and commands to run the frontend.
2 changes: 1 addition & 1 deletion smartcontracts/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def abi_path(name) -> str:


typescript_content = f"""
import {{ GenericContractsDeclaration }} from "~~/utils/scaffold-eth/contract";
import {{ GenericContractsDeclaration }} from "~~/utils/fwt/contract";
const deployedContracts = {{
{CHAIN_ID}: {dumps({
Expand Down
2 changes: 1 addition & 1 deletion ui/app/blockexplorer/_components/AddressLogsTab.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address } from "viem";
import { useContractLogs } from "~~/hooks/scaffold-eth";
import { replacer } from "~~/utils/scaffold-eth/common";
import { replacer } from "~~/utils/fwt/common";

export const AddressLogsTab = ({ address }: { address: Address }) => {
const contractLogs = useContractLogs(address);
Expand Down
4 changes: 2 additions & 2 deletions ui/app/blockexplorer/_components/TransactionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { TransactionHash } from "./TransactionHash";
import { formatEther } from "viem";
import { Address } from "~~/components/scaffold-eth";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { TransactionWithFunction } from "~~/utils/scaffold-eth";
import { TransactionsTableProps } from "~~/utils/scaffold-eth/";
import { TransactionWithFunction } from "~~/utils/fwt";
import { TransactionsTableProps } from "~~/utils/fwt/";

export const TransactionsTable = ({ blocks, transactionReceipts }: TransactionsTableProps) => {
const { targetNetwork } = useTargetNetwork();
Expand Down
4 changes: 2 additions & 2 deletions ui/app/blockexplorer/address/[address]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import path from "path";
import { hardhat } from "viem/chains";
import { AddressComponent } from "~~/app/blockexplorer/_components/AddressComponent";
import deployedContracts from "~~/contracts/deployedContracts";
import { isZeroAddress } from "~~/utils/scaffold-eth/common";
import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
import { isZeroAddress } from "~~/utils/fwt/common";
import { GenericContractsDeclaration } from "~~/utils/fwt/contract";

type PageProps = {
params: { address: string };
Expand Down
4 changes: 2 additions & 2 deletions ui/app/blockexplorer/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getMetadata } from "~~/utils/scaffold-eth/getMetadata";
import { getMetadata } from "~~/utils/fwt/getMetadata";

export const metadata = getMetadata({
title: "Block Explorer",
description: "Block Explorer created with 🏗 Scaffold-ETH 2",
description: "Block Explorer created with 🏗 Fullstack Web3 Template",
});

const BlockExplorerLayout = ({ children }: { children: React.ReactNode }) => {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/blockexplorer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { NextPage } from "next";
import { hardhat } from "viem/chains";
import { useFetchBlocks } from "~~/hooks/scaffold-eth";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { notification } from "~~/utils/scaffold-eth";
import { notification } from "~~/utils/fwt";

const BlockExplorer: NextPage = () => {
const { blocks, transactionReceipts, currentPage, totalBlocks, setCurrentPage, error } = useFetchBlocks();
Expand Down
2 changes: 1 addition & 1 deletion ui/app/blockexplorer/transaction/[txHash]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TransactionComp from "../_components/TransactionComp";
import type { NextPage } from "next";
import { Hash } from "viem";
import { isZeroAddress } from "~~/utils/scaffold-eth/common";
import { isZeroAddress } from "~~/utils/fwt/common";

type PageProps = {
params: { txHash?: Hash };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { hardhat } from "viem/chains";
import { usePublicClient } from "wagmi";
import { Address } from "~~/components/scaffold-eth";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { decodeTransactionData, getFunctionDetails } from "~~/utils/scaffold-eth";
import { replacer } from "~~/utils/scaffold-eth/common";
import { decodeTransactionData, getFunctionDetails } from "~~/utils/fwt";
import { replacer } from "~~/utils/fwt/common";

const TransactionComp = ({ txHash }: { txHash: Hash }) => {
const client = usePublicClient({ chainId: hardhat.id });
Expand Down
4 changes: 2 additions & 2 deletions ui/app/debug/_components/DebugContracts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useEffect, useMemo } from "react";
import { useLocalStorage } from "usehooks-ts";
import { BarsArrowUpIcon } from "@heroicons/react/20/solid";
import { ContractUI } from "~~/app/debug/_components/contract";
import { ContractName, GenericContract } from "~~/utils/scaffold-eth/contract";
import { useAllContracts } from "~~/utils/scaffold-eth/contractsData";
import { ContractName, GenericContract } from "~~/utils/fwt/contract";
import { useAllContracts } from "~~/utils/fwt/contractsData";

const selectedContractStorageKey = "scaffoldEth2.selectedContract";

Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/ContractInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
IntegerInput,
IntegerVariant,
} from "~~/components/scaffold-eth";
import { AbiParameterTuple } from "~~/utils/scaffold-eth/contract";
import { AbiParameterTuple } from "~~/utils/fwt/contract";

type ContractInputProps = {
setForm: Dispatch<SetStateAction<Record<string, any>>>;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/ContractReadMethods.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Abi, AbiFunction } from "abitype";
import { ReadOnlyFunctionForm } from "~~/app/debug/_components/contract";
import { Contract, ContractName, GenericContract, InheritedFunctions } from "~~/utils/scaffold-eth/contract";
import { Contract, ContractName, GenericContract, InheritedFunctions } from "~~/utils/fwt/contract";

export const ContractReadMethods = ({ deployedContractData }: { deployedContractData: Contract<ContractName> }) => {
if (!deployedContractData) {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/ContractUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ContractWriteMethods } from "./ContractWriteMethods";
import { Address, Balance } from "~~/components/scaffold-eth";
import { useDeployedContractInfo, useNetworkColor } from "~~/hooks/scaffold-eth";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { ContractName } from "~~/utils/scaffold-eth/contract";
import { ContractName } from "~~/utils/fwt/contract";

type ContractUIProps = {
contractName: ContractName;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/ContractVariables.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DisplayVariable } from "./DisplayVariable";
import { Abi, AbiFunction } from "abitype";
import { Contract, ContractName, GenericContract, InheritedFunctions } from "~~/utils/scaffold-eth/contract";
import { Contract, ContractName, GenericContract, InheritedFunctions } from "~~/utils/fwt/contract";

export const ContractVariables = ({
refreshDisplayVariables,
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/ContractWriteMethods.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Abi, AbiFunction } from "abitype";
import { WriteOnlyFunctionForm } from "~~/app/debug/_components/contract";
import { Contract, ContractName, GenericContract, InheritedFunctions } from "~~/utils/scaffold-eth/contract";
import { Contract, ContractName, GenericContract, InheritedFunctions } from "~~/utils/fwt/contract";

export const ContractWriteMethods = ({
onChange,
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/DisplayVariable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useReadContract } from "wagmi";
import { ArrowPathIcon } from "@heroicons/react/24/outline";
import { useAnimationConfig } from "~~/hooks/scaffold-eth";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { getParsedError, notification } from "~~/utils/scaffold-eth";
import { getParsedError, notification } from "~~/utils/fwt";

type DisplayVariableProps = {
contractAddress: Address;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/ReadOnlyFunctionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
transformAbiFunction,
} from "~~/app/debug/_components/contract";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { getParsedError, notification } from "~~/utils/scaffold-eth";
import { getParsedError, notification } from "~~/utils/fwt";

type ReadOnlyFunctionFormProps = {
contractAddress: Address;
Expand Down
4 changes: 2 additions & 2 deletions ui/app/debug/_components/contract/Tuple.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Dispatch, SetStateAction, useEffect, useState } from "react";
import { ContractInput } from "./ContractInput";
import { getFunctionInputKey, getInitialTupleFormState } from "./utilsContract";
import { replacer } from "~~/utils/scaffold-eth/common";
import { AbiParameterTuple } from "~~/utils/scaffold-eth/contract";
import { replacer } from "~~/utils/fwt/common";
import { AbiParameterTuple } from "~~/utils/fwt/contract";

type TupleProps = {
abiTupleParameter: AbiParameterTuple;
Expand Down
4 changes: 2 additions & 2 deletions ui/app/debug/_components/contract/TupleArray.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Dispatch, SetStateAction, useEffect, useState } from "react";
import { ContractInput } from "./ContractInput";
import { getFunctionInputKey, getInitialTupleArrayFormState } from "./utilsContract";
import { replacer } from "~~/utils/scaffold-eth/common";
import { AbiParameterTuple } from "~~/utils/scaffold-eth/contract";
import { replacer } from "~~/utils/fwt/common";
import { AbiParameterTuple } from "~~/utils/fwt/contract";

type TupleArrayProps = {
abiTupleParameter: AbiParameterTuple & { isVirtual?: true };
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/TxReceipt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import CopyToClipboard from "react-copy-to-clipboard";
import { TransactionReceipt } from "viem";
import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline";
import { ObjectFieldDisplay } from "~~/app/debug/_components/contract";
import { replacer } from "~~/utils/scaffold-eth/common";
import { replacer } from "~~/utils/fwt/common";

export const TxReceipt = ({ txResult }: { txResult: TransactionReceipt }) => {
const [txResultCopied, setTxResultCopied] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/utilsContract.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AbiFunction, AbiParameter } from "abitype";
import { AbiParameterTuple } from "~~/utils/scaffold-eth/contract";
import { AbiParameterTuple } from "~~/utils/fwt/contract";

/**
* Generates a key based on function metadata
Expand Down
2 changes: 1 addition & 1 deletion ui/app/debug/_components/contract/utilsDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ReactElement, useState } from "react";
import { TransactionBase, TransactionReceipt, formatEther, isAddress, isHex } from "viem";
import { ArrowsRightLeftIcon } from "@heroicons/react/24/solid";
import { Address } from "~~/components/scaffold-eth";
import { replacer } from "~~/utils/scaffold-eth/common";
import { replacer } from "~~/utils/fwt/common";

type DisplayContent =
| string
Expand Down
4 changes: 2 additions & 2 deletions ui/app/debug/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DebugContracts } from "./_components/DebugContracts";
import type { NextPage } from "next";
import { getMetadata } from "~~/utils/scaffold-eth/getMetadata";
import { getMetadata } from "~~/utils/fwt/getMetadata";

export const metadata = getMetadata({
title: "Debug Contracts",
description: "Debug your deployed 🏗 Scaffold-ETH 2 contracts in an easy way",
description: "Debug your deployed 🏗 Fullstack Web3 Template contracts in an easy way",
});

const Debug: NextPage = () => {
Expand Down
6 changes: 3 additions & 3 deletions ui/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import "@rainbow-me/rainbowkit/styles.css";
import { ScaffoldEthAppWithProviders } from "~~/components/ScaffoldEthAppWithProviders";
import { ThemeProvider } from "~~/components/ThemeProvider";
import "~~/styles/globals.css";
import { getMetadata } from "~~/utils/scaffold-eth/getMetadata";
import { getMetadata } from "~~/utils/fwt/getMetadata";

export const metadata = getMetadata({
title: "Scaffold-ETH 2 App",
description: "Built with 🏗 Scaffold-ETH 2",
title: "Fullstack Web3 Template App",
description: "Built with 🏗 Fullstack Web3 Template",
});

const ScaffoldEthApp = ({ children }: { children: React.ReactNode }) => {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Home: NextPage = () => {
<div className="px-5">
<h1 className="text-center">
<span className="block text-2xl mb-2">Welcome to</span>
<span className="block text-4xl font-bold">Scaffold-ETH 2</span>
<span className="block text-4xl font-bold">Fullstack Web3 Template</span>
</h1>
<div className="flex justify-center items-center space-x-2 flex-col sm:flex-row">
<p className="my-2 font-medium">Connected Address:</p>
Expand Down
4 changes: 2 additions & 2 deletions ui/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export const Header = () => {
<Image alt="SE2 logo" className="cursor-pointer" fill src="/logo.svg" />
</div>
<div className="flex flex-col">
<span className="font-bold leading-tight">Scaffold-ETH</span>
<span className="text-xs">Ethereum dev stack</span>
<span className="font-bold leading-tight">FWT</span>
<span className="text-xs">Fullstack Web3 Template</span>
</div>
</Link>
<ul className="hidden lg:flex lg:flex-nowrap menu menu-horizontal px-1 gap-2">
Expand Down
2 changes: 1 addition & 1 deletion ui/components/scaffold-eth/Address/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { normalize } from "viem/ens";
import { useEnsAvatar, useEnsName } from "wagmi";
import { BlockieAvatar } from "~~/components/scaffold-eth";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { getBlockExplorerAddressLink } from "~~/utils/scaffold-eth";
import { getBlockExplorerAddressLink } from "~~/utils/fwt";

const textSizeMap = {
"3xs": "text-[10px]",
Expand Down
2 changes: 1 addition & 1 deletion ui/components/scaffold-eth/Faucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useAccount } from "wagmi";
import { BanknotesIcon } from "@heroicons/react/24/outline";
import { Address, AddressInput, Balance, EtherInput } from "~~/components/scaffold-eth";
import { useTransactor } from "~~/hooks/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";
import { notification } from "~~/utils/fwt";

// Account index to use from generated hardhat accounts.
const FAUCET_ACCOUNT_INDEX = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "@heroicons/react/24/outline";
import { BlockieAvatar, isENS } from "~~/components/scaffold-eth";
import { useOutsideClick } from "~~/hooks/scaffold-eth";
import { getTargetNetworks } from "~~/utils/scaffold-eth";
import { getTargetNetworks } from "~~/utils/fwt";

const allowedNetworks = getTargetNetworks();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTheme } from "next-themes";
import { useAccount, useSwitchChain } from "wagmi";
import { ArrowsRightLeftIcon } from "@heroicons/react/24/solid";
import { getNetworkColor } from "~~/hooks/scaffold-eth";
import { getTargetNetworks } from "~~/utils/scaffold-eth";
import { getTargetNetworks } from "~~/utils/fwt";

const allowedNetworks = getTargetNetworks();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ConnectButton } from "@rainbow-me/rainbowkit";
import { Address } from "viem";
import { useNetworkColor } from "~~/hooks/scaffold-eth";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { getBlockExplorerAddressLink } from "~~/utils/scaffold-eth";
import { getBlockExplorerAddressLink } from "~~/utils/fwt";

/**
* Custom Wagmi Connect Button (watch balance + custom design)
Expand Down
2 changes: 1 addition & 1 deletion ui/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
import { GenericContractsDeclaration } from "~~/utils/fwt/contract";

const deployedContracts = {
31337: {"Counter": {"address": "0x610178da211fef7d417bc0e6fed39f05609ad788", "abi": [{"type": "function", "name": "getError", "inputs": [], "outputs": [], "stateMutability": "pure"}, {"type": "function", "name": "increment", "inputs": [], "outputs": [], "stateMutability": "nonpayable"}, {"type": "function", "name": "number", "inputs": [], "outputs": [{"name": "", "type": "uint256", "internalType": "uint256"}], "stateMutability": "view"}, {"type": "function", "name": "setNumber", "inputs": [{"name": "newNumber", "type": "uint256", "internalType": "uint256"}], "outputs": [], "stateMutability": "nonpayable"}, {"type": "function", "name": "withdraw", "inputs": [{"name": "amount", "type": "uint256", "internalType": "uint256"}], "outputs": [], "stateMutability": "pure"}, {"type": "error", "name": "CustomError", "inputs": [{"name": "message", "type": "string", "internalType": "string"}]}, {"type": "error", "name": "InsufficientBalance", "inputs": [{"name": "available", "type": "uint256", "internalType": "uint256"}, {"name": "required", "type": "uint256", "internalType": "uint256"}]}]}}
Expand Down
2 changes: 1 addition & 1 deletion ui/contracts/externalContracts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract";
import { GenericContractsDeclaration } from "~~/utils/fwt/contract";

/**
* @example
Expand Down
2 changes: 1 addition & 1 deletion ui/hooks/scaffold-eth/useDeployedContractInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
import { useTargetNetwork } from "./useTargetNetwork";
import { useIsMounted } from "usehooks-ts";
import { usePublicClient } from "wagmi";
import { Contract, ContractCodeStatus, ContractName, contracts } from "~~/utils/scaffold-eth/contract";
import { Contract, ContractCodeStatus, ContractName, contracts } from "~~/utils/fwt/contract";

/**
* Gets the matching contract info for the provided contract name from the contracts present in deployedContracts.ts
Expand Down
Loading

0 comments on commit f1570aa

Please sign in to comment.