{"id":18487223,"url":"https://github.com/compound-developers/api-guide-example","last_synced_at":"2025-04-08T20:30:51.718Z","repository":{"id":42832233,"uuid":"248610198","full_name":"compound-developers/api-guide-example","owner":"compound-developers","description":"Example Ethereum smart contract API made with Express.js and Infura.","archived":false,"fork":false,"pushed_at":"2023-01-24T02:37:17.000Z","size":69,"stargazers_count":39,"open_issues_count":9,"forks_count":22,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-06T02:59:02.926Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/compound-developers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-19T21:38:23.000Z","updated_at":"2022-09-21T22:20:31.000Z","dependencies_parsed_at":"2023-01-28T00:45:55.627Z","dependency_job_id":null,"html_url":"https://github.com/compound-developers/api-guide-example","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compound-developers%2Fapi-guide-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compound-developers%2Fapi-guide-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compound-developers%2Fapi-guide-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compound-developers%2Fapi-guide-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compound-developers","download_url":"https://codeload.github.com/compound-developers/api-guide-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223343662,"owners_count":17129953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-06T12:50:20.196Z","updated_at":"2024-11-06T12:51:47.128Z","avatar_url":"https://github.com/compound-developers.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Smart Contract API Example\n\nExample code for building your own Ethereum smart contract API in [Node.js](https://nodejs.org/en/download/).\n\n## Setup\n\n```\ngit clone git@github.com:compound-developers/api-guide-example.git\ncd api-guide-example\nnpm install\n```\n\n**config.json**\n\nThe listed contract addresses and ABIs might be out of date. They can be confirmed here https://compound.finance/docs#networks.\n\n**server.js**\n\n1. Be sure to set an environment variable for the Ethereum wallet private \nkey.\n2. Replace the HTTP Provider URL with your own. [Infura provides free API keys](https://infura.io/).\n\n```js\nconst walletPrivateKey = process.env.walletPrivateKey;\nconst web3 = new Web3('https://mainnet.infura.io/v3/_your_api_key_here_');\n```\n\n## Running\n\n```\nnode server.js\n```\n\n## API Endpoint Example Calls\n\nThese are the possible calls that can be made with [cURL](https://curl.haxx.se/download.html).\n\n```bash\ncurl localhost:3000/wallet-balance/eth/\ncurl localhost:3000/wallet-balance/ceth/\ncurl localhost:3000/supply/eth/9000\ncurl localhost:3000/protocol-balance/eth/\ncurl localhost:3000/redeem/eth/123\n```\n\nHere is an example of outputs for a series of API calls. The wallet started out with 100 ETH.\n\n```bash\ncurl localhost:3000/wallet-balance/eth/\n\u003e 100\n\ncurl localhost:3000/wallet-balance/ceth/\n\u003e 0\n\ncurl localhost:3000/supply/eth/5\n\u003e OK\n\ncurl localhost:3000/protocol-balance/eth/\n\u003e 4.999999999885010676\n\ncurl localhost:3000/wallet-balance/eth/\n\u003e 94.99788632\n\ncurl localhost:3000/wallet-balance/ceth/\n\u003e 249.85542658\n\ncurl localhost:3000/redeem/eth/249.85542658\n\u003e OK\n\ncurl localhost:3000/protocol-balance/eth/\n\u003e 0\n\ncurl localhost:3000/wallet-balance/ceth/\n\u003e 0\n\ncurl localhost:3000/wallet-balance/eth/\n\u003e 99.995909700269046879\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompound-developers%2Fapi-guide-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompound-developers%2Fapi-guide-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompound-developers%2Fapi-guide-example/lists"}