{"id":13392612,"url":"https://github.com/cjgdev/smart-contract-patterns","last_synced_at":"2026-01-17T09:52:36.726Z","repository":{"id":79451155,"uuid":"66352761","full_name":"cjgdev/smart-contract-patterns","owner":"cjgdev","description":"Smart-Contract Patterns written in Solidity, collated for community good","archived":false,"fork":false,"pushed_at":"2016-08-23T16:06:30.000Z","size":11,"stargazers_count":59,"open_issues_count":1,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-10T19:19:32.084Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cjgdev.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":"security/circuit_breaker.sol","support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-08-23T09:23:46.000Z","updated_at":"2024-09-24T08:46:06.000Z","dependencies_parsed_at":"2023-03-12T08:13:02.501Z","dependency_job_id":null,"html_url":"https://github.com/cjgdev/smart-contract-patterns","commit_stats":null,"previous_names":["blockchaindev/smart-contract-patterns"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjgdev%2Fsmart-contract-patterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjgdev%2Fsmart-contract-patterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjgdev%2Fsmart-contract-patterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjgdev%2Fsmart-contract-patterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjgdev","download_url":"https://codeload.github.com/cjgdev/smart-contract-patterns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243459119,"owners_count":20294342,"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-07-30T17:00:29.458Z","updated_at":"2026-01-17T09:52:36.683Z","avatar_url":"https://github.com/cjgdev.png","language":null,"funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# Smart-Contract Patterns\n\nWriting good software has never been an easy task, however the introduction of\ncommon design patterns by the gang of four (Gamma, Helm, Johnson, Vlissides) in\ntheir seminal book 'Design Patterns' in 1995, went a long way to creating a\nlanguage of patterns, an essential method of describing solutions to common\nproblems.\n\nThis is a library of smart-contract patterns written in `Solidity`. Writing\nsmart-contracts has been proven to be difficult, exemplified by TheDAO in recent\nevents. It is my intention that this repository will serve the community by\ncollating the most useful smart-contract patterns for public benefit.\n\n## Patterns\n\nThe patterns are logically divided into four groupings. `Lifetime` is a group of\npatterns that control the construction and destruction of smart-contracts.\n`Maintenance` is a group of patterns that provide mechanisms for live contracts.\n`Ownership` is a group of patterns that control access to smart-contract. And\nfinally `Security` is a group of patterns that seek to mitigate security related\nmatters.\n\n### Lifetime\n\n`auto_deprecation` - Provides a mechanism for automatic expiration of a contract\ninterface after some period of time has elapsed.\n[lifetime/auto_deprecation.sol](lifetime/auto_deprecation.sol)\n\n`mortal` - Provides a method for the creator of a contract to destroy it.\n[lifetime/mortal.sol](lifetime/mortal.sol)\n\n### Maintenance\n\n`relay` - Provides a method for the creator of a contract to update it to a\nnewer version without invalidating the address.\n[maintenance/relay.sol](maintenance/relay.sol)\n\n`data_segregation` - Segregates a contract and its data so as to avoid costly\ndata migrations.\n[maintenance/data_segregation.sol](maintenance/data_segregation.sol)\n\n### Ownership\n\n`owner` - Limits access to certain functions to only the owner of the contract.\n[ownership/owner.sol](ownership/owner.sol)\n\n### Security\n\n`circuit_breaker` - The circuit breaker pattern allows the owner to disable or\nenable a contract by a runtime toggle.\n[security/circuit_breaker.sol](security/circuit_breaker.sol)\n\n`rejector` - The rejector pattern automatically rejects all ether sent to it.\n[security/rejector.sol](security/rejector.sol)\n\n`speed_bump` - The speed bump pattern limits how often a function can be called\nto deliberately slow down certain functions.\n[security/speed_bump.sol](security/speed_bump.sol)\n\n## Contributions\n\nContributions are welcome. Please use the issue tracker to submit requests or\nreport issues.\n\nIf you would like to submit a pattern to the library, please first submit a\nproposal via the issue tracker.\n\n## License\n\nThe code contained within this repository is licensed and distributed under the\nApache 2.0 license. It is my intention to invite derivative works, as well as\nencourage commercial use without obligation.\n\n[LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjgdev%2Fsmart-contract-patterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjgdev%2Fsmart-contract-patterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjgdev%2Fsmart-contract-patterns/lists"}