A Next.js application for viewing verified smart contract details from the Sourcify API.
- Node.js 18.x or later
- npm or yarn
- Docker (optional, for containerized deployment)
Create a .env file in the root directory with the following variables:
SOURCIFY_SERVER_URL=https://sourcify.dev/server
SOURCIFY_SERVER_INTERNAL_URL=https://sourcify.dev/server
# NODE_ENV=development or NODE_ENV=productionSOURCIFY_SERVER_URL: the public URL of the Sourcify server. The browser uses it (similarity verification) and so do redirects, so it must be reachable from the internet.SOURCIFY_SERVER_INTERNAL_URL: the URL the Next.js server uses for its own calls to the Sourcify server (contract pages are rendered server-side). Locally this is just the public URL again. In production it must be the Sourcify server's direct service URL (its Cloud Run*.run.appURL, without the/serverpath prefix) so the traffic stays inside the network instead of leaving and re-entering through the public load balancer, where a per-IP rate limit would put every visitor's page view in one shared bucket. Both are required and checked innext.config.ts, sonext buildandnext devfail immediately when one is missing. Pass both at build time (the growthepie top-contracts route is pre-rendered duringnext build) and at runtime, in every environment that builds the app: Cloud Build, Netlify deploy previews, local.env.
-
Clone the repository:
git clone https://github.com/sourcifyeth/repo.sourcify.dev.git cd repo.sourcify.dev -
Install dependencies:
npm install # or yarn install -
Run the development server:
npm run dev # or yarn dev -
Open http://localhost:3000 in your browser to see the application.
npm run build
npm start
# or
yarn build
yarn startThe project includes a Dockerfile based on the official Next.js Docker example.
Keep in mind you need to pass the SOURCIFY_SERVER_URL as a build argument. The way to pass this might differ depending on your build platform. In Google Cloud Build, you need to pass it as a value to be substituted in your cloudbuild.yaml file:
steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- "--build-arg"
- "SOURCIFY_SERVER_URL=${_SOURCIFY_SERVER_URL}"
- "--build-arg"
- "SOURCIFY_SERVER_INTERNAL_URL=${_SOURCIFY_SERVER_INTERNAL_URL}"
---
substitutions:
_SOURCIFY_SERVER_URL: https://sourcify.dev/server
_SOURCIFY_SERVER_INTERNAL_URL: https://<sourcify-server-service>.a.run.app-
Build the Docker image:
# Build the image with the Sourcify server URL as a build argument docker build --build-arg SOURCIFY_SERVER_URL=https://sourcify.dev/server --build-arg SOURCIFY_SERVER_INTERNAL_URL=https://sourcify.dev/server -t repo-sourcify .
-
Run the container:
docker run -p 3000:3000 -e SOURCIFY_SERVER_URL=https://sourcify.dev/server -e SOURCIFY_SERVER_INTERNAL_URL=https://sourcify.dev/server repo-sourcify
-
Access the application at http://localhost:3000.