This repository contains the subgraph implementations for the Morpheus protocol, supporting three networks: Base, Arbitrum, and Arbitrum Sepolia.
The repository is organized as follows:
morpheus-subgraph/
├── schema.graphql # Schema for Base and Arbitrum
├── schema-sepolia.graphql # Schema for Arbitrum Sepolia
├── base-subgraph.yaml # Subgraph manifest for Base
├── arbitrum-subgraph.yaml # Subgraph manifest for Arbitrum
├── arbitrum-sepolia-subgraph.yaml # Subgraph manifest for Arbitrum Sepolia
├── src/
│ ├── subnet-registry-mapping.ts # Mapping for Subnet entities
│ ├── builders-project-registry-mapping.ts # Mapping for Base/Arbitrum builders
│ ├── builder-subnet-registry-mapping.ts # Mapping for Arbitrum Sepolia builders
│ └── provider-registry-mapping.ts # Mapping for Provider entities
├── abis/ # Contract ABIs
└── generated/ # Generated AssemblyScript types (created during build)
-
Install the Graph CLI:
npm install -g @graphprotocol/graph-cli
-
Install dependencies:
npm install
- Get access to Satsuma and create a new subgraph
- Generate the AssemblyScript types:
graph codegen --config base-subgraph.yaml
- Build the subgraph:
graph build --config base-subgraph.yaml
- Deploy to Satsuma:
graph deploy --config base-subgraph.yaml --node https://subgraph.satsuma-prod.com/api/deploy --ipfs https://ipfs.satsuma-prod.com --access-token YOUR_SATSUMA_TOKEN
- Create a new subgraph in The Graph Studio
- Generate the AssemblyScript types:
graph codegen --config arbitrum-subgraph.yaml
- Build the subgraph:
graph build --config arbitrum-subgraph.yaml
- Authenticate with The Graph:
graph auth --studio YOUR_DEPLOY_KEY
- Deploy to The Graph Studio:
graph deploy --studio your-subgraph-name
- Get access to Satsuma and create a new subgraph
- Generate the AssemblyScript types:
graph codegen --config arbitrum-sepolia-subgraph.yaml
- Build the subgraph:
graph build --config arbitrum-sepolia-subgraph.yaml
- Deploy to Satsuma:
graph deploy --config arbitrum-sepolia-subgraph.yaml --node https://subgraph.satsuma-prod.com/api/deploy --ipfs https://ipfs.satsuma-prod.com --access-token YOUR_SATSUMA_TOKEN
Before deploying, make sure to update the contract addresses in each subgraph.yaml file:
- SubnetRegistry:
0x...
- BuildersProjectRegistry:
0x...
- ProviderRegistry:
0x...
- SubnetRegistry:
0x...
- BuildersProjectRegistry:
0x...
- ProviderRegistry:
0x...
- SubnetRegistry:
0x...
- BuilderSubnetRegistry:
0x...
- ProviderRegistry:
0x...
You can get the current contract addresses by checking the existing subgraphs or asking the protocol team.
In your NextJS application, you should create an adapter layer to handle the differences between these subgraphs. See the morpheus-subgraph-schema.md
document for detailed examples of how to build this adapter.
This is a Next.js project bootstrapped with create-next-app
.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx
. The page auto-updates as you edit the file.
This project uses next/font
to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
This project supports multiple networks including both mainnet and testnet environments:
- Ethereum
- Arbitrum One
- Base
- Arbitrum Sepolia
- Visual Indicators: Clear testnet indicator in the navbar when using test networks
- Network-Specific Balances: Displays MOR token balances for the appropriate networks
- Contract Address Management: Centralized contract address configuration in
config/networks.ts
- Type Safety: Fully typed with TypeScript for better developer experience
The network functionality is implemented using:
- Configuration: A centralized configuration system in
config/networks.ts
that defines all networks and contract addresses - Wagmi Integration: Uses wagmi hooks for blockchain interactions and network state management
- UI Components:
mor-balance.tsx
: Displays MOR token balances for relevant networkstestnet-indicator.tsx
: Shows a clear visual indicator when on testnet
To access network state and contract addresses in your components:
import { useChainId } from 'wagmi'
import { morTokenContracts } from '@/lib/contracts'
function MyComponent() {
const chainId = useChainId()
const isTestnet = chainId === 421614 // Arbitrum Sepolia
// Use the network state in your component
// ...
}
- Always check the current chainId before making transactions
- Use the contract addresses from config instead of hardcoding addresses
- Handle both mainnet and testnet cases in your components
- Test thoroughly on testnets before deploying to mainnet