Skip to content

Commit

Permalink
Merge pull request #10 from jar-o/main
Browse files Browse the repository at this point in the history
Scaffold-ETH 2 migration
  • Loading branch information
jar-o authored Jul 9, 2024
2 parents 2d6c73a + 22e56e0 commit 8ea836e
Show file tree
Hide file tree
Showing 719 changed files with 119,503 additions and 8,553 deletions.
62 changes: 50 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
# 🏗 Scaffold-ETH 2
# OracleReader based on Scaffold-ETH 2

To run this example, which uses the Foundry tooling, we first need to fork the [Sepolia network](https://sepolia.etherscan.io/).

In a terminal window do

```
export ETH_RPC_URL='https://your-sepolia-rpc-server/etc'
yarn chainsep
```

In a second terminal window do

```
export DEPLOYER_PRIVATE_KEY="0xdeadbeefcafebabe"
cd packages/foundry
cp .env.example .env
yarn deploy
```

when this completes, you should be see a contract address in the output:

```
...
##### sepolia
✅ [Success]Hash: 0xda5b4871929d1414a5b447769f4d8d757b1aea8e280555adb9dd7ec67bb6b683
Contract Address: 0xA2B4473120b9d18abfE90EEb2722A57CB72C4212
```

Now, you can verify that you can read with the Foundry `cast` command:

```
🦄 cast call 0xA2B4473120b9d18abfE90EEb2722A57CB72C4212 'read()(uint)'
3319415000000000000000 [3.319e21]
```

Note that because this is a fork of the Sepolia network, you should be getting a pretty up-to-date value for `ETH/USD`.

# 🏗 Scaffold-ETH 2 [ORIGINAL README]

<h4 align="center">
<a href="https://docs.scaffoldeth.io">Documentation</a> |
Expand All @@ -7,7 +45,7 @@

🧪 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, Viem, and Typescript.
⚙️ Built using NextJS, RainbowKit, Foundry, Wagmi, Viem, and Typescript.

-**Contract Hot Reload**: Your frontend auto-adapts to your smart contract as you edit it.
- 🪝 **[Custom hooks](https://docs.scaffoldeth.io/hooks/)**: Collection of React hooks wrapper around [wagmi](https://wagmi.sh/) to simplify interactions with smart contracts with typescript autocompletion.
Expand All @@ -29,11 +67,10 @@ Before you begin, you need to install the following tools:

To get started with Scaffold-ETH 2, follow the steps below:

1. Clone this repo & install dependencies
1. Install dependencies if it was skipped in CLI:

```
git clone https://github.com/scaffold-eth/scaffold-eth-2.git
cd scaffold-eth-2
cd my-dapp-example
yarn install
```

Expand All @@ -43,15 +80,15 @@ yarn install
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`.
This command starts a local Ethereum network using Foundry. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in `packages/foundry/foundry.toml`.

3. 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.
This command deploys a test smart contract to the local network. The contract is located in `packages/foundry/contracts` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/foundry/script` to deploy the contract to the network. You can also customize the deploy script.

4. On a third terminal, start your NextJS app:

Expand All @@ -61,11 +98,12 @@ yarn start

Visit your app on: `http://localhost:3000`. You can interact with your smart contract using the `Debug Contracts` page. You can tweak the app config in `packages/nextjs/scaffold.config.ts`.

Run smart contract test with `yarn hardhat:test`
Run smart contract test with `yarn foundry:test`

- Edit your smart contract `YourContract.sol` in `packages/foundry/contracts`
- Edit your frontend homepage at `packages/nextjs/app/page.tsx`. For guidance on [routing](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation.
- Edit your deployment scripts in `packages/foundry/script`

- Edit your smart contract `YourContract.sol` in `packages/hardhat/contracts`
- Edit your frontend in `packages/nextjs/pages`
- Edit your deployment scripts in `packages/hardhat/deploy`

## Documentation

Expand All @@ -77,4 +115,4 @@ To know more about its features, check out our [website](https://scaffoldeth.io)

We welcome contributions to Scaffold-ETH 2!

Please see [CONTRIBUTING.MD](https://github.com/scaffold-eth/scaffold-eth-2/blob/main/CONTRIBUTING.md) for more information and guidelines for contributing to Scaffold-ETH 2.
Please see [CONTRIBUTING.MD](https://github.com/scaffold-eth/scaffold-eth-2/blob/main/CONTRIBUTING.md) for more information and guidelines for contributing to Scaffold-ETH 2.
51 changes: 29 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,42 @@
"private": true,
"workspaces": {
"packages": [
"packages/hardhat",
"packages/nextjs"
"packages/*"
]
},
"scripts": {
"account": "yarn workspace @se-2/hardhat account",
"chain": "yarn workspace @se-2/hardhat chain",
"fork": "yarn workspace @se-2/hardhat fork",
"deploy": "yarn workspace @se-2/hardhat deploy",
"verify": "yarn workspace @se-2/hardhat verify",
"hardhat-verify": "yarn workspace @se-2/hardhat hardhat-verify",
"compile": "yarn workspace @se-2/hardhat compile",
"generate": "yarn workspace @se-2/hardhat generate",
"hardhat:lint": "yarn workspace @se-2/hardhat lint",
"hardhat:lint-staged": "yarn workspace @se-2/hardhat lint-staged",
"hardhat:test": "yarn workspace @se-2/hardhat test",
"test": "yarn hardhat:test",
"start": "yarn workspace @se-2/nextjs dev",
"next:lint": "yarn workspace @se-2/nextjs lint",
"next:format": "yarn workspace @se-2/nextjs format",
"next:check-types": "yarn workspace @se-2/nextjs check-types",
"account": "yarn workspace @se-2/foundry account",
"chain": "yarn workspace @se-2/foundry chain",
"chainsep": "yarn workspace @se-2/foundry chainsep",
"compile": "yarn workspace @se-2/foundry compile",
"deploy": "yarn workspace @se-2/foundry deploy",
"deploy:verify": "yarn workspace @se-2/foundry deploy:verify",
"flatten": "yarn workspace @se-2/foundry flatten",
"fork": "yarn workspace @se-2/foundry fork",
"format": "yarn next:format && yarn foundry:format",
"foundry:format": "yarn workspace @se-2/foundry format",
"foundry:lint": "yarn workspace @se-2/foundry lint",
"foundry:test": "yarn workspace @se-2/foundry test",
"generate": "yarn workspace @se-2/foundry generate",
"postinstall": "husky install",
"next:build": "yarn workspace @se-2/nextjs build",
"next:check-types": "yarn workspace @se-2/nextjs check-types",
"next:format": "yarn workspace @se-2/nextjs format",
"next:lint": "yarn workspace @se-2/nextjs lint",
"next:serve": "yarn workspace @se-2/nextjs serve",
"precommit": "lint-staged",
"start": "yarn workspace @se-2/nextjs dev",
"test": "yarn foundry:test",
"vercel": "yarn workspace @se-2/nextjs vercel",
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo"
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo",
"verify": "yarn workspace @se-2/foundry verify"
},
"packageManager": "[email protected]",
"devDependencies": {
"husky": "^8.0.1",
"lint-staged": "^13.0.3"
"husky": "~8.0.3",
"lint-staged": "~13.2.2"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=18.17.0"
}
}
8 changes: 8 additions & 0 deletions packages/foundry/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DEPLOYER_PRIVATE_KEY=
ETHERSCAN_API_KEY=
ALCHEMY_API_KEY=

# The Chronicle ETH/USD oracle on Sepolia.
CHRONICLE_ORACLE=0xdd6D76262Fd7BdDe428dcfCd94386EbAe0151603
# The Chronicle SelfKisser contract on Sepolia.
SELF_KISSER=0x0Dcc19657007713483A5cA76e6A7bbe5f56EA37d
14 changes: 14 additions & 0 deletions packages/foundry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
localhost.json
6 changes: 6 additions & 0 deletions packages/foundry/.prettier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"tabWidth": 2,
"trailingComma": "all"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"transactions": [
{
"hash": "0xda5b4871929d1414a5b447769f4d8d757b1aea8e280555adb9dd7ec67bb6b683",
"transactionType": "CREATE",
"contractName": "OracleReader",
"contractAddress": "0xa2b4473120b9d18abfe90eeb2722a57cb72c4212",
"function": null,
"arguments": [
"0xdd6D76262Fd7BdDe428dcfCd94386EbAe0151603",
"0x0Dcc19657007713483A5cA76e6A7bbe5f56EA37d"
],
"transaction": {
"from": "0x39abd7819e5632fa06d2ecbba45dca5c90687ee3",
"gas": "0x43c63",
"value": "0x0",
"input": "0x60c060405234801561001057600080fd5b506040516102b63803806102b683398101604081905261002f916100bb565b6001600160a01b03828116608081905290821660a081905260405163c529a67960e01b815260048101929092529063c529a67990602401600060405180830381600087803b15801561008057600080fd5b505af1158015610094573d6000803e3d6000fd5b5050505050506100ee565b80516001600160a01b03811681146100b657600080fd5b919050565b600080604083850312156100ce57600080fd5b6100d78361009f565b91506100e56020840161009f565b90509250929050565b60805160a05161019f6101176000396000604b01526000818160a5015260cb015261019f6000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806332f929fc1461004657806357de26a41461008a578063a34fa092146100a0575b600080fd5b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b6100926100c7565b604051908152602001610081565b61006d7f000000000000000000000000000000000000000000000000000000000000000081565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166357de26a46040518163ffffffff1660e01b8152600401602060405180830381865afa158015610127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061014b9190610150565b905090565b60006020828403121561016257600080fd5b505191905056fea26469706673582212208171d90821f24165a244cd58296d8fc377933541495688233f9cec0ab27025ad64736f6c63430008150033000000000000000000000000dd6d76262fd7bdde428dcfcd94386ebae01516030000000000000000000000000dcc19657007713483a5ca76e6a7bbe5f56ea37d",
"nonce": "0x33c",
"chainId": "0xaa36a7"
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"status": "0x1",
"cumulativeGasUsed": "0x34255",
"logs": [
{
"address": "0xdd6d76262fd7bdde428dcfcd94386ebae0151603",
"topics": [
"0x75d30ca40c7bcd48e685894b82b864808b9cb566090efc53444a2e61742f18a3",
"0x0000000000000000000000000dcc19657007713483a5ca76e6a7bbe5f56ea37d",
"0x000000000000000000000000a2b4473120b9d18abfe90eeb2722a57cb72c4212"
],
"data": "0x",
"blockHash": "0x1b9223f34d862974e464028c955e3f43b319850ac6fdee340192495b824334e5",
"blockNumber": "0x5f34ab",
"blockTimestamp": "0x668590f5",
"transactionHash": "0xda5b4871929d1414a5b447769f4d8d757b1aea8e280555adb9dd7ec67bb6b683",
"transactionIndex": "0x0",
"logIndex": "0x0",
"removed": false
},
{
"address": "0x0dcc19657007713483a5ca76e6a7bbe5f56ea37d",
"topics": [
"0x3b6e7e6ff858d016edf22112c8596ecf8f0a55591a3b84c35b993e0de85a0c84",
"0x000000000000000000000000a2b4473120b9d18abfe90eeb2722a57cb72c4212",
"0x000000000000000000000000dd6d76262fd7bdde428dcfcd94386ebae0151603",
"0x000000000000000000000000a2b4473120b9d18abfe90eeb2722a57cb72c4212"
],
"data": "0x",
"blockHash": "0x1b9223f34d862974e464028c955e3f43b319850ac6fdee340192495b824334e5",
"blockNumber": "0x5f34ab",
"blockTimestamp": "0x668590f5",
"transactionHash": "0xda5b4871929d1414a5b447769f4d8d757b1aea8e280555adb9dd7ec67bb6b683",
"transactionIndex": "0x0",
"logIndex": "0x1",
"removed": false
}
],
"logsBloom": "0x00000000000008000000000000040000040000000000000000000000000000000000000000000000020000000000000000800000000000000000000000000000000000000000000000020000000000000000000020000000000000000000000000000080000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000008000000000000080000000000040020000000000000000001000000000000000000000000000000000000000000002000000000000000000000000000000000040000000000000000000000000000000000080000040000000000200000000000000",
"type": "0x0",
"transactionHash": "0xda5b4871929d1414a5b447769f4d8d757b1aea8e280555adb9dd7ec67bb6b683",
"transactionIndex": "0x0",
"blockHash": "0x1b9223f34d862974e464028c955e3f43b319850ac6fdee340192495b824334e5",
"blockNumber": "0x5f34ab",
"gasUsed": "0x34255",
"effectiveGasPrice": "0x3eba38bf4",
"blobGasPrice": "0x2c7c04a10",
"from": "0x39abd7819e5632fa06d2ecbba45dca5c90687ee3",
"to": null,
"contractAddress": "0xa2b4473120b9d18abfe90eeb2722a57cb72c4212",
"root": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
],
"libraries": [],
"pending": [],
"returns": {},
"timestamp": 1720029434,
"chain": 11155111,
"commit": "ef41476"
}
File renamed without changes.
2 changes: 2 additions & 0 deletions packages/foundry/deployments/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore 31337 deployments
31337.json
3 changes: 3 additions & 0 deletions packages/foundry/deployments/11155111.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"networkName": "Sepolia"
}
40 changes: 40 additions & 0 deletions packages/foundry/foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[profile.default]
src = 'contracts'
out = 'out'
libs = ['lib']
fs_permissions = [{ access = "read-write", path = "./"}]

[rpc_endpoints]
default_network = "http://127.0.0.1:8545"
localhost = "http://127.0.0.1:8545"

mainnet = "https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_API_KEY}"
sepolia = "https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
arbitrum = "https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
arbitrumSepolia = "https://arb-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
optimism = "https://opt-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
optimismSepolia = "https://opt-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
polygon = "https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
polygonMumbai = "https://polygon-mumbai.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
gnosis = "https://rpc.gnosischain.com"
chiado = "https://rpc.chiadochain.net"
base = "https://mainnet.base.org"
baseGoerli = "https://goerli.base.org"
baseSepolia = "https://sepolia.base.org"
polygonZkEvm = "https://polygonzkevm-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
polygonZkEvmTestnet = "https://polygonzkevm-testnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
zkSyncTestnet = "https://testnet.era.zksync.dev"
zkSync = "https://mainnet.era.zksync.io"
scrollSepolia = "https://sepolia-rpc.scroll.io"
scroll = "https://rpc.scroll.io"

[etherscan]
polygonMumbai = { key = "${ETHERSCAN_API_KEY}" }
sepolia = { key = "${ETHERSCAN_API_KEY}" }


[fmt]
line_length = 80
multiline_func_header = "params_first"

# See more config options https://github.com/foundry-rs/foundry/tree/master/config
1 change: 1 addition & 0 deletions packages/foundry/lib/forge-std/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/Vm.sol linguist-generated
Loading

0 comments on commit 8ea836e

Please sign in to comment.