This example shows how to create a GraphQL API for an ERC20 token using Ponder. It uses the Adventure Gold token contract on Ethereum (Link).
{
account(id: "0x1337f7970E8399ccbc625647FCE58a9dADA5aA66") {
balance
approvals {
spender
amount
}
}
}{
accounts(first: 10, orderBy: "balance", orderDirection: "desc") {
id
balance
}
}{
accounts(where: { isOwner: true }) {
id
}
}{
account(id: "0x1337f7970E8399ccbc625647FCE58a9dADA5aA66") {
transferEventsTo {
from
amount
}
transferEventsFrom {
to
amount
}
}
}The application uses PostgreSQL as its database. When running with Docker Compose, the database is automatically configured and connected. The default credentials are:
- Database: ponder_db
- Username: ponder
- Password: ponderpass
- Host: localhost (or postgres when accessing from within Docker)
- Port: 5432
For local development without Docker, you'll need to:
- Install PostgreSQL
- Create a database named
ponder_db - Set the DATABASE_URL in your .env.local file:
DATABASE_URL=postgresql://ponder:ponderpass@localhost:5432/ponder_db
For production, make sure to:
- Use strong, unique passwords
- Configure proper database backups
- Set up appropriate database access controls