{"id":22649994,"url":"https://github.com/gitericsson/graphql_smart_contract","last_synced_at":"2026-04-15T05:31:23.707Z","repository":{"id":265633738,"uuid":"895974671","full_name":"gitEricsson/GraphQL_Smart_Contract","owner":"gitEricsson","description":"This project is a GraphQL server that interacts with an Ethereum smart contract using Hardhat and Ethers.js. The server allows users to increment a counter stored on the blockchain and retrieve its current value. It also includes a MongoDB database for user management.","archived":false,"fork":false,"pushed_at":"2024-11-30T07:59:06.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-04T05:58:02.791Z","etag":null,"topics":["ethereum","ethersjs","graphql","hardhat","mongodb","mongoose","smart-contract","solidity","web3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gitEricsson.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-29T09:45:42.000Z","updated_at":"2024-11-30T07:59:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"981533dc-1e25-4fc2-aeba-12a440be41fd","html_url":"https://github.com/gitEricsson/GraphQL_Smart_Contract","commit_stats":null,"previous_names":["gitericsson/graphql_smart_contract"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gitEricsson/GraphQL_Smart_Contract","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FGraphQL_Smart_Contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FGraphQL_Smart_Contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FGraphQL_Smart_Contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FGraphQL_Smart_Contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitEricsson","download_url":"https://codeload.github.com/gitEricsson/GraphQL_Smart_Contract/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitEricsson%2FGraphQL_Smart_Contract/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31828530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethereum","ethersjs","graphql","hardhat","mongodb","mongoose","smart-contract","solidity","web3"],"created_at":"2024-12-09T08:29:50.905Z","updated_at":"2026-04-15T05:31:23.686Z","avatar_url":"https://github.com/gitEricsson.png","language":"TypeScript","readme":"# GraphQL Smart Contract\n\n## Overview\n\nThis project is a GraphQL server that interacts with an Ethereum smart contract using Hardhat and Ethers.js. The server allows users to increment a counter stored on the blockchain and retrieve its current value. It also includes a MongoDB database for user management.\n\n## Table of Contents\n\n- [Features](#features)\n- [Technologies Used](#technologies-used)\n- [Installation](#installation)\n- [Configuration](#configuration)\n- [Running the Project](#running-the-project)\n- [API Endpoints](#api-endpoints)\n- [Smart Contract](#smart-contract)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- GraphQL API for interacting with a smart contract.\n- Increment and retrieve a counter stored on the Ethereum blockchain.\n- User management with MongoDB.\n- Environment variable configuration for sensitive data.\n\n## Technologies Used\n\n- **Node.js**: JavaScript runtime for building the server.\n- **Express**: Web framework for Node.js.\n- **GraphQL**: Query language for APIs.\n- **Ethers.js**: Library for interacting with the Ethereum blockchain.\n- **Hardhat**: Development environment for Ethereum.\n- **MongoDB**: NoSQL database for storing user data.\n- **TypeScript**: Superset of JavaScript for type safety.\n\n## Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/yourusername/simple_graphql_smart_contract.git\n   cd simple_graphql_smart_contract\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   npm install\n   ```\n\n3. Set up your environment variables. Create a `.env` file in the root directory and add the following:\n\n   ```plaintext\n   MONGODB_URI=your_mongodb_uri\n   MONGO_PASSWORD=your_mongo_password\n   PORT=4000\n   CONTRACT_ADDRESS=your_contract_address\n   PROVIDER_URL=https://your_provider_url\n   PRIVATE_KEY=your_private_key\n   INFURA_PRIVATE_KEY=your_infura_private_key\n   ```\n\n## Configuration\n\nThe project uses a configuration file located at `src/config/config.ts`. This file loads environment variables and provides them to the application. Ensure that you have the correct values set in your `.env` file.\n\n## Running the Project\n\n1. Compile the TypeScript code:\n\n   ```bash\n   npm run build\n   ```\n\n2. Start the server:\n\n   ```bash\n   npm start\n   ```\n\n3. The server will run at `http://localhost:4000/graphql`.\n\n## API Endpoints\n\n### Queries\n\n- **getCounter**: Retrieves the current value of the counter from the smart contract.\n\n  **Example Query**:\n\n  ```graphql\n  query {\n    getCounter\n  }\n  ```\n\n- **getUsers**: Retrieves a list of users from the MongoDB database.\n\n  **Example Query**:\n\n  ```graphql\n  query {\n    getUsers {\n      id\n      name\n      email\n    }\n  }\n  ```\n\n### Mutations\n\n- **incrementCounter**: Increments the counter in the smart contract.\n\n  **Example Mutation**:\n\n  ```graphql\n  mutation {\n    incrementCounter\n  }\n  ```\n\n- **addUser**: Adds a new user to the MongoDB database.\n\n  **Example Mutation**:\n\n  ```graphql\n  mutation {\n    addUser(name: \"John Doe\", email: \"john@example.com\") {\n      id\n      name\n      email\n    }\n  }\n  ```\n\n## Smart Contract\n\nThe smart contract is located in `src/contracts/Counter.sol`. It includes the following functions:\n\n- **increment**: Increments the counter and emits an event.\n- **getCounter**: Returns the current value of the counter.\n\n## Contributing\n\nContributions are welcome! Please fork the repository and submit a pull request with your changes.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitericsson%2Fgraphql_smart_contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitericsson%2Fgraphql_smart_contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitericsson%2Fgraphql_smart_contract/lists"}