{"id":18334187,"url":"https://github.com/wbuchwalter/circleci-ethereum","last_synced_at":"2026-03-06T10:30:51.712Z","repository":{"id":66049794,"uuid":"79853850","full_name":"wbuchwalter/circleci-ethereum","owner":"wbuchwalter","description":"CI/CD for Ethereum Smart Contracts with CircleCI and Truffle","archived":false,"fork":false,"pushed_at":"2017-02-14T23:54:44.000Z","size":24374,"stargazers_count":22,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-30T14:26:30.592Z","etag":null,"topics":["blockchain","circleci","devops","ethereum","truffle"],"latest_commit_sha":null,"homepage":"","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/wbuchwalter.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-23T22:15:26.000Z","updated_at":"2023-12-26T23:47:21.000Z","dependencies_parsed_at":"2023-04-04T15:19:36.483Z","dependency_job_id":null,"html_url":"https://github.com/wbuchwalter/circleci-ethereum","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wbuchwalter/circleci-ethereum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbuchwalter%2Fcircleci-ethereum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbuchwalter%2Fcircleci-ethereum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbuchwalter%2Fcircleci-ethereum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbuchwalter%2Fcircleci-ethereum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wbuchwalter","download_url":"https://codeload.github.com/wbuchwalter/circleci-ethereum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wbuchwalter%2Fcircleci-ethereum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30171869,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["blockchain","circleci","devops","ethereum","truffle"],"created_at":"2024-11-05T19:47:14.767Z","updated_at":"2026-03-06T10:30:51.691Z","avatar_url":"https://github.com/wbuchwalter.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CI/CD for Ethereum Smart Contracts with CircleCI and Truffle\n\nCI/CD walk-through of a simple demo app (Metacoin by Truffle) using CircleCI and docker.\n\n\u003e If you are interested in doing CI on a windows agent with Visual Studio Team Services instead, take a look at [David Burela's article](https://davidburela.wordpress.com/2016/12/23/ethereum-devops-with-truffle-testrpc-visual-studio-team-services/)\n\n\n### Configuring the agent requirements\nFirst, we need to request an agent with the docker service enable, because we will be using `Geth` and `testrpc` in containers.  \nWe also want the latest nodejs version.\n \nIn `circleci.yml`:\n```yaml\nmachine:\n  services:\n    - docker\n  node:\n    version: 7.4.0\n```\n\n### Installing the dependencies\n\nWe will need [truffle](https://github.com/ConsenSys/truffle) to test and migrate our smart contracts, and [web3](https://github.com/ethereum/web3.js/) to have a JavaScript API for Ethereum.\nThe easiest way to install them is to use npm.  \nSpecify this dependencies in your `package.json`:\n```json\n  \"dependencies\": {\n    \"truffle\": \"^2.1.1\",\n    \"web3\": \"^0.18.2\"\n  }\n```\n\nBy default, CircleCI will detect your `package.json` file and automatically run `npm install`, so you don't need to add anything in your `circleci.yml` at this point.\n\n### Testing the Contract\n\nCircleCI will also run `npm test` just after finishing `npm install`, so we need to modify our `package.json` to correctly launch our tests.  \nThe easiest way to test a smart contract, is by deploying on an in-memory simulated blockchain. [`testrpc`](https://github.com/ethereumjs/testrpc) allows us to do just that.\nFor convenience, we are going to use launch `testrpc` inside a container, that way we don't have to deal with installing the depencies.  \nYou can either build the image yourself from the [`Dockerfile`](https://github.com/ethereumjs/testrpc/blob/master/Dockerfile) or use an existing one: [wbuchwalter/testrpc](https://hub.docker.com/r/wbuchwalter/testrpc/)\n\nIf not already done, you need to configure `truffle` with the correct RPC endpoint and network id ([`truffle.js`](truffle.js)).\n\nHere is what our `package.json` script section will look like:\n\n```json\n\"scripts\": {\n    \"test\": \"docker run -d -p 8545:8545 --name testrpc wbuchwalter/testrpc  \u0026\u0026 truffle test\",\n    \"posttest\": \"docker stop testrpc\"\n  }\n```\nWe are starting the `testrpc` container in the background (-d) and exposing the `8545` port on the same port on localhost so that truffle can connect.\nThe `posttest` script will be executed after the `test` script automatically, and ensures we stop our `testrpc` container so that the port `8545` is freed.\n\n\n### Deploying/Migrating Contracts\n\nNow that our tests are successful you might want to deploy it on a test environment, or directly on your production blockchain.\nTo keep this example simple, we are going to do the former.\n\nAgain, we will be using Geth in a container as well. The official image for Geth is [`ethereum/client-go`](https://hub.docker.com/r/ethereum/client-go/).\n\nHere is what `circleci.yml` will look like:\n```yaml\ndeployment:\n  production:\n    branch: master\n    commands:\n      - docker run -it -v $(pwd):/app ethereum/client-go --datadir /app/geth/data init /app/genesis.json\n      - docker run -d -p 8545:8545 -v $(pwd):/app ethereum/client-go --datadir /app/geth/data --networkid 20170123 --rpc --unlock 0x322ba17d251afdb6d84fd288b5aef518208cccb9 --password /app/password --rpcaddr \"0.0.0.0\" --verbosity 5\n      - node scripts/waitForEthSync.js\n      - truffle migrate\n```\n\nThe first commands starts Geth, and call `init`. We need to mount the current directory into the container (`-v $(pwd):/app`) so that Geth can access `geth/data` and `genesis.json`.  \n\nOnce this is done we actually start the Geth node:\n``` bash\ndocker run -d \\ #Run in background\n-p 8545:8545 \\ #Expose port 8545 so that truffle can connect\n-v $(pwd):/app \\ #Mount the working directory inside the container \nethereum/client-go \\ #image name\n--datadir /app/geth/data \\\n--networkid 20170123 \\ \n--rpc \\\n--unlock 0x322ba17d251afdb6d84fd288b5aef518208cccb9 \\ #unlock an account from the keystore that can submit transactions\n--password /app/password \\ #file containing the password to unlock the account\n--rpcaddr \"0.0.0.0\" \\ #allow localholst connections\n--verbosity 5 \\ #easier debugging\n```\n\nFor simplicity, the password is stored in a file in the git repository. This is obviously not ideal. Instead you should use something like CircleCI's environment variables.\n\nThis command will start the syncrhonization of the Geth node with the blockchain. This can take a while (you could also use the `--fast` flag), so we need to wait for it to finish before calling `truffle migrate`.\nFor this purpose, I created a node script([`./scripts/waitForEthSync.js`](./scripts/waitForEthSync.js)), that will connect to the node, and block the deployment pipeline until the syncrhonization is complete:\n```JavaScript\nattemptConnection('http://0.0.0.0:8545').then(waitForSync).catch(console.log)\n``` \n\nOnce the synchronization completed we can submit our migration with `truffle migrate`\n\n\nYou should now have a pipeline similar to this one: [wbuchwalter/circleci-ethereum/48](https://circleci.com/gh/wbuchwalter/circleci-ethereum/48)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbuchwalter%2Fcircleci-ethereum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwbuchwalter%2Fcircleci-ethereum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwbuchwalter%2Fcircleci-ethereum/lists"}