Skip to content

Commit

Permalink
Merge pull request #11 from chronicleprotocol/Streamline
Browse files Browse the repository at this point in the history
Streamline tutorial
  • Loading branch information
biancabuzea200 authored Oct 1, 2024
2 parents 8ea836e + 972c69c commit bd19fb6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 72 deletions.
Binary file added OracleReader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 34 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,7 @@
# OracleReader based on Scaffold-ETH 2
# 🏗 OracleReader Built 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> |
<a href="https://scaffoldeth.io">Website</a>
</h4>

🧪 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.
🧪 An open-source, toolkit for building decentralized applications (dapps) on the Ethereum blockchain and integrating with Chronicle Oracles. 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, Foundry, Wagmi, Viem, and Typescript.

Expand All @@ -53,7 +11,8 @@ Note that because this is a fork of the Sepolia network, you should be getting a
- 🔥 **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.

![Debug Contracts tab](https://github.com/scaffold-eth/scaffold-eth-2/assets/55535804/b237af0c-5027-4849-a5c1-2e31495cccb1)
![Oracle Reader](OracleReader.png)


## Requirements

Expand All @@ -63,34 +22,55 @@ Before you begin, you need to install the following tools:
- Yarn ([v1](https://classic.yarnpkg.com/en/docs/install/) or [v2+](https://yarnpkg.com/getting-started/install))
- [Git](https://git-scm.com/downloads)

## Quickstart
## 🏃🏻‍♂️ Running It

To get started with Scaffold-ETH 2, follow the steps below:
To run this example, which uses the Foundry tooling in conjunction with [Scaffold-ETH2](https://scaffoldeth.io), you first need to fork the [Sepolia network](https://sepolia.etherscan.io/).

1. Install dependencies if it was skipped in CLI:
In a terminal window install dependencies:

```
cd my-dapp-example
yarn install
```

2. Run a local network in the first terminal:
Fork your target network, leave this terminal window open as it runs your local chain.

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

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:

In a second terminal window, you can now deploy your contracts to the local chain:

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

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.
When this completes, you should see a contract address in the output:

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

4. On a third terminal, start your NextJS app:
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`.


You can now start your NextJS app:

```
yarn start
Expand All @@ -103,16 +83,3 @@ 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`


## Documentation

Visit our [docs](https://docs.scaffoldeth.io) to learn how to start building with Scaffold-ETH 2.

To know more about its features, check out our [website](https://scaffoldeth.io).

## Contributing to Scaffold-ETH 2

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.
4 changes: 2 additions & 2 deletions packages/foundry/deployments/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Ignore 31337 deployments
31337.json
# Ignore 11155111 deployments
11155111.json
5 changes: 2 additions & 3 deletions packages/foundry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"scripts": {
"account": "node script/ListAccount.js",
"chain": "anvil --config-out localhost.json",
"chainsep": "anvil --fork-url ${ETH_RPC_URL}",
"compile": "forge compile",
"deploy": "forge build --build-info --build-info-path out/build-info/ && forge script script/Deploy.s.sol --rpc-url ${1:-default_network} --broadcast --legacy && node script/generateTsAbis.js",
"deploy": "forge build --build-info --build-info-path out/build-info/ && forge script script/Deploy.s.sol --rpc-url ${1:-default_network} --broadcast --legacy && node script/generateTsAbis.js --chain-id 31337",
"deploy:verify": "forge build --build-info --build-info-path out/build-info/ && forge script script/Deploy.s.sol --rpc-url ${1:-default_network} --broadcast --legacy --verify ; node script/generateTsAbis.js",
"flatten": "forge flatten",
"fork": "anvil --fork-url ${0:-mainnet} --chain-id 31337 --config-out localhost.json",
"fork": "anvil --fork-url ${ETH_RPC_URL} --chain-id 31337 --config-out localhost.json",
"format": "forge fmt && prettier --write ./script/**/*.js",
"generate": "node script/generateAccount.js",
"lint": "forge fmt --check && prettier --check ./script/**/*.js",
Expand Down

0 comments on commit bd19fb6

Please sign in to comment.