Skip to content

Commit

Permalink
DAPP v1 done.
Browse files Browse the repository at this point in the history
  • Loading branch information
halokid committed Dec 6, 2022
1 parent 64f6f58 commit ae116a7
Show file tree
Hide file tree
Showing 53 changed files with 26,257 additions and 6 deletions.
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Temporary Items
/ML-AI-sample/.vscode
/java_basic/*.class
/py_Parallel/.idea
<<<<<<< HEAD
/java_aop/.idea
=======
/py_Parallel/process_allinone/*.pyc
Expand All @@ -69,19 +68,15 @@ Temporary Items
/java-junit-sample/*.iml
/java-junit-sample/.idea
/daily_tools/SyncTags/src/main/java/com/inif/数据库连接.java
<<<<<<< HEAD
/java_aop/*.iml
/daily_tools/jiankongbao/.idea
/daily_tools/jiankongbao/*.iml
/daily_tools/jiankongbao/jiankongbao/*.exe
=======
>>>>>>> 2f15e2490f29f9d1f35be53e4e05ba51a457abb4
>>>>>>> 2a3f6f5341f23b9d2bd1bb8551b139f0a18aeb6a
/tensorflow/.idea
/tensorflow/tf_in_action/*.meta
/tensorflow/tf_in_action/*.index
/tensorflow/tf_in_action/*.data-00000-of-00001
<<<<<<< HEAD
/MachineLearn-DeepLearn-AI/.idea
/make_python_package/.idea
/make_python_package/MyPackage/__pycache__/*.pyc
Expand All @@ -95,7 +90,6 @@ Temporary Items
/aliyun_java_edu/aliyun-r00xx/target/classes/util/*.class
/golang_natural_blockchain/.idea
/why_backend_use_golang/.idea
>>>>>>> 361ebd811267c236128f185aecb34f1c58fe326b
/golang_basic/.idea
/golang_rpc/.idea
/golang_coroutine_sample/.idea
Expand Down Expand Up @@ -125,3 +119,6 @@ ms_react_guide/mslearn-react/code/0-starter/node_modules
/springCloudSampleDemo/.idea
/springCloudSampleDemo/service-hi/.mvn/wrapper
/springCloudSampleDemo/eureka-server/.mvn/wrapper
.env
contract-abi.json
web3/alchemy_sample/tutorial/hello-world/artifacts
35 changes: 35 additions & 0 deletions web3/alchemy_sample/go_sample/c1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"context"
"fmt"
"log"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)

func main() {
client, err := ethclient.Dial("https://eth-goerli.g.alchemy.com/v2/Ocf_EETGbdsBqKJ3f-DNC4YfxK7F1JB9")
if err != nil {
log.Fatal(err)
}

// Get the balance of an account
account := common.HexToAddress("0x9851099eF06BAD791045281c193847CF32da70E8")
balance, err := client.BalanceAt(context.Background(), account, nil)
if err != nil {
log.Fatal(err)
}
fmt.Println("Account balance:", balance) // 25893180161173005034

// Get the latest known block
block, err := client.BlockByNumber(context.Background(), nil)
if err != nil {
log.Fatal(err)
}
fmt.Println("Latest block:", block.Number().Uint64())
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
package-lock.json
node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# solidity
solidity-stuff/

#env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 📝 Hello World Part Four Tutorial

This repository contains the starter files (`starter-files`) and completed version (`completed`) of Alchemy's [Hello World Part 4 Tutorial](https://app.gitbook.com/@alchemyapi/s/alchemy/tutorials/hello-world-smart-contract/creating-a-full-stack-dapp).

## ℹ️ About the tutorial

In this tutorial, we'll teach you how to create a full stack dApp by connecting your Hello World smart contract to a React frontend using Metamask and Web3 tools.

## 🤔 Note

Niether the `starter-files` nor `completed` have their `node_modules` folder. Before running `npm start` in your terminal to start the React project, run `npm install` to download all the package dependencies.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# [Completed] Hello World Part 4 Tutorial

This project contains the COMPLETED files for [Alchemy's Hello World Part 4](https://docs.alchemy.com/alchemy/tutorials/hello-world-smart-contract/creating-a-full-stack-dapp), in which we teach you how to create a full stack dApp by connecting your Hello World smart contract to a React frontend using Metamask and Web3 tools.

# 🪜 Installation
To use this dApp, you'll need to do the following:

1. Run `npm install` to download the `node_modules` folder.
2. Download the [dotenv package](https://www.npmjs.com/package/dotenv) in your project directory by running `npm install dotenv --save` in your terminal
3. Create a `.env` file in the root directory this `nft-minter` by entering the following on your command line: `vim .env` and then add your [Alchemy API Key](https://docs.alchemy.com/alchemy/tutorials/hello-world-smart-contract/creating-a-full-stack-dapp#establish-an-api-connection-to-the-ethereum-chain). Altogether, your `.env` file should just look like so:

```
REACT_APP_ALCHEMY_KEY = wss://eth-ropsten.ws.alchemyapi.io/v2/<key>
```
4. Run `npm start`in your terminal to open the dApp in your browswer at http://localhost:3000/.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "hello-world-part-four",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"dotenv": "^9.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Hello World Part 4 by Alchemy</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import HelloWorld from './HelloWorld'
import './App.css';

function App() {
return (
<div className="App">
<HelloWorld></HelloWorld>
</div>
);
}

export default App;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
Loading

0 comments on commit ae116a7

Please sign in to comment.