Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
w1nt3r-eth committed Sep 28, 2022
0 parents commit 0826a65
Show file tree
Hide file tree
Showing 19 changed files with 2,688 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALCHEMY_API_KEY=
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

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

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
.env
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Guess ABI of any Ethereum contract, even if it is not verified on Etherscan. Works by analyzing the bytecode,
extracting selectors from PUSH4/JUMPI instructions and comparing them to known ABI signatures.

Powered by <a href="https://github.com/shazow/whatsabi">@shazow/whatsabi</a> and <a href="https://www.4byte.directory/">4byte.directory</a>

## Getting Started

Copy `.env.example` to `.env` and add your Alchemy API key.

Then, run the development server:

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

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
13 changes: 13 additions & 0 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function Footer() {
return (
<footer>
Powered by <a href="https://github.com/shazow/whatsabi">@shazow/whatsabi</a> and{' '}
<a href="https://www.4byte.directory/">4byte.directory</a>
<style jsx>{`
footer {
margin-top: 2rem;
}
`}</style>
</footer>
);
}
28 changes: 28 additions & 0 deletions components/HeadMeta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Head from 'next/head';

type Props = {
title: string;
description: string;
};

const BASE_URL = 'https://abi.w1nt3r.xyz';

export default function HeadMeta(props: Props) {
return (
<Head>
<title>{props.title}</title>
<meta name="description" content={props.description} />
<link rel="icon" href="/favicon.png" />
<meta property="og:title" content={props.title} />
<meta property="og:description" content={props.description} />
<meta property="og:image" content={`${BASE_URL}/og_image.png`} />
<meta property="og:url" content={`${BASE_URL}`} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@w1nt3r_eth" />
<meta name="twitter:creator" content="@w1nt3r_eth" />
<meta name="twitter:title" content={props.title} />
<meta name="twitter:description" content={props.description} />
<meta name="twitter:image" content={`${BASE_URL}/og_image.png`} />
</Head>
);
}
7 changes: 7 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
}

module.exports = nextConfig
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "whatsabi",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"prettier": {
"singleQuote": true,
"printWidth": 120
},
"dependencies": {
"@shazow/whatsabi": "^0.1.0",
"ethers": "^5.7.1",
"next": "12.3.1",
"prettier": "^2.7.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "18.7.23",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"eslint": "8.24.0",
"eslint-config-next": "12.3.1",
"typescript": "4.8.4"
}
}
8 changes: 8 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import '../styles/globals.css'
import type { AppProps } from 'next/app'

function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}

export default MyApp
13 changes: 13 additions & 0 deletions pages/api/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next'

type Data = {
name: string
}

export default function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
res.status(200).json({ name: 'John Doe' })
}
67 changes: 67 additions & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { NextPage } from 'next';
import Footer from '../components/Footer';
import HeadMeta from '../components/HeadMeta';

// TODO: Using Next's <Link> component for navigation is not showing loading state
/* eslint-disable @next/next/no-html-link-for-pages */

const Home: NextPage = () => {
return (
<div className="container">
<HeadMeta title="ABI for unverified contracts" description="Guess ABI of any Ethereum contract" />

<main className="main">
<h1 className="title">Get ABI for unverified contracts</h1>

<p className="description">
Guess ABI of any Ethereum contract, even if it is not verified on Etherscan. Works by analyzing the bytecode,
extracting selectors from PUSH4/JUMPI instructions and comparing them to known ABI signatures.
</p>

<form action="/search" method="get">
<input
name="address"
type="search"
placeholder="0x123...abc"
required
autoFocus
autoCapitalize="none"
autoCorrect="false"
spellCheck="false"
autoComplete="off"
/>
<button type="submit"></button>
</form>
<p className="description">Or try some examples:</p>
<p className="description">
<a href="/mainnet/0x7a250d5630b4cf539739df2c5dacb4c659f2488d">0x7a250d5630b4cf539739df2c5dacb4c659f2488d</a>
<br />
<a href="/mainnet/0x2d8a1e139cb15319b1f325eb917c9c704f45db7c">0x2d8a1e139cb15319b1f325eb917c9c704f45db7c</a>
<br />
<a href="/mainnet/0xaE9C73fd0Fd237c1c6f66FE009d24ce969e98704">0xaE9C73fd0Fd237c1c6f66FE009d24ce969e98704</a>
</p>

<Footer />
</main>
<style jsx>{`
.main {
padding: 2rem;
max-width: 60ch;
}
form {
display: flex;
}
input {
width: 100%;
padding: 0.5rem;
font-size: 1.5rem;
}
button {
width: 50px;
}
`}</style>
</div>
);
};

export default Home;
Loading

0 comments on commit 0826a65

Please sign in to comment.