{"action":"created","comment":{"url":"https://api.github.com/repos/ethereum/solidity/pulls/comments/255626474","pull_request_review_id":202254549,"id":255626474,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI1NTYyNjQ3NA==","diff_hunk":"@@ -0,0 +1,57 @@\n+.. index:: contract;modular, modular contract\n+\n+*****************\n+Modular Contracts\n+*****************\n+\n+A modular approach to building your contracts helps you prevent overflow risks\n+and unexpected tokens. In the example below, the contract uses the ``send`` method\n+of the ``Balances`` :ref:`library <libraries>` to check that balances sent between\n+addresses match what you expect.\n+\n+::\n+\n+    pragma solidity >=0.4.22 <0.6.0;\n+\n+    library Balances {\n+        function move(mapping(address => uint256) storage balances, address from, address to, uint amount) internal {\n+            require(balances[from] >= amount);\n+            require(balances[to] + amount >= balances[to]);\n+            balances[from] -= amount;\n+            balances[to] += amount;\n+        }\n+    }\n+\n+    contract Token {\n+        mapping(address => uint256) balances;\n+        using Balances for *;\n+        mapping(address => mapping (address => uint256)) allowed;\n+\n+        event Transfer(address from, address to, uint amount);\n+        event Approval(address owner, address spender, uint amount);\n+\n+        function balanceOf(address tokenOwner) public view returns (uint balance) {\n+            return balances[tokenOwner];\n+        }\n+        function transfer(address to, uint amount) public returns (bool success) {\n+            balances.move(msg.sender, to, amount);\n+            emit Transfer(msg.sender, to, amount);\n+            return true;\n+\n+        }\n+\n+        function transferFrom(address from, address to, uint amount) public returns (bool success) {\n+            require(allowed[from][msg.sender] >= amount);\n+            allowed[from][msg.sender] -= amount;\n+            balances.send(from, to, amount);","path":"docs/examples/modular.rst","position":46,"original_position":46,"commit_id":"799e2070af0b202bd13d9026e6d345459d48a538","original_commit_id":"799e2070af0b202bd13d9026e6d345459d48a538","user":{"login":"leonardoalt","id":504195,"node_id":"MDQ6VXNlcjUwNDE5NQ==","avatar_url":"https://avatars1.githubusercontent.com/u/504195?v=4","gravatar_id":"","url":"https://api.github.com/users/leonardoalt","html_url":"https://github.com/leonardoalt","followers_url":"https://api.github.com/users/leonardoalt/followers","following_url":"https://api.github.com/users/leonardoalt/following{/other_user}","gists_url":"https://api.github.com/users/leonardoalt/gists{/gist_id}","starred_url":"https://api.github.com/users/leonardoalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonardoalt/subscriptions","organizations_url":"https://api.github.com/users/leonardoalt/orgs","repos_url":"https://api.github.com/users/leonardoalt/repos","events_url":"https://api.github.com/users/leonardoalt/events{/privacy}","received_events_url":"https://api.github.com/users/leonardoalt/received_events","type":"User","site_admin":false},"body":"```suggestion\r\n            balances.move(from, to, amount);\r\n```","created_at":"2019-02-11T18:03:14Z","updated_at":"2019-02-11T18:03:19Z","html_url":"https://github.com/ethereum/solidity/pull/5962#discussion_r255626474","pull_request_url":"https://api.github.com/repos/ethereum/solidity/pulls/5962","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/comments/255626474"},"html":{"href":"https://github.com/ethereum/solidity/pull/5962#discussion_r255626474"},"pull_request":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/5962"}}},"pull_request":{"url":"https://api.github.com/repos/ethereum/solidity/pulls/5962","id":251902989,"node_id":"MDExOlB1bGxSZXF1ZXN0MjUxOTAyOTg5","html_url":"https://github.com/ethereum/solidity/pull/5962","diff_url":"https://github.com/ethereum/solidity/pull/5962.diff","patch_url":"https://github.com/ethereum/solidity/pull/5962.patch","issue_url":"https://api.github.com/repos/ethereum/solidity/issues/5962","number":5962,"state":"open","locked":false,"title":"[DOCS] Create modular example","user":{"login":"ChrisChinchilla","id":42080,"node_id":"MDQ6VXNlcjQyMDgw","avatar_url":"https://avatars2.githubusercontent.com/u/42080?v=4","gravatar_id":"","url":"https://api.github.com/users/ChrisChinchilla","html_url":"https://github.com/ChrisChinchilla","followers_url":"https://api.github.com/users/ChrisChinchilla/followers","following_url":"https://api.github.com/users/ChrisChinchilla/following{/other_user}","gists_url":"https://api.github.com/users/ChrisChinchilla/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisChinchilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisChinchilla/subscriptions","organizations_url":"https://api.github.com/users/ChrisChinchilla/orgs","repos_url":"https://api.github.com/users/ChrisChinchilla/repos","events_url":"https://api.github.com/users/ChrisChinchilla/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisChinchilla/received_events","type":"User","site_admin":false},"body":"### Description\r\n\r\nCloses https://github.com/ethereum/solidity/issues/4636\r\n\r\nI wonder if the example needs more explanation? Nicely this also properly closes an FAQ point that we closed a while back that related to checking balances.\r\n\r\n### Checklist\r\n- [x] Code compiles correctly\r\n- [ ] All tests are passing\r\n- [x] New tests have been created which fail without the change (if possible)\r\n- [x] README / documentation was extended, if necessary\r\n- [x] Changelog entry (if change is visible to the user)\r\n- [x] Used meaningful commit messages\r\n","created_at":"2019-02-11T12:53:37Z","updated_at":"2019-02-11T18:03:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"539324490497ba701674c804440be33d5ff58558","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ethereum/solidity/pulls/5962/commits","review_comments_url":"https://api.github.com/repos/ethereum/solidity/pulls/5962/comments","review_comment_url":"https://api.github.com/repos/ethereum/solidity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethereum/solidity/issues/5962/comments","statuses_url":"https://api.github.com/repos/ethereum/solidity/statuses/799e2070af0b202bd13d9026e6d345459d48a538","head":{"label":"ethereum:docs-modular-example","ref":"docs-modular-example","sha":"799e2070af0b202bd13d9026e6d345459d48a538","user":{"login":"ethereum","id":6250754,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYyNTA3NTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6250754?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":40892817,"node_id":"MDEwOlJlcG9zaXRvcnk0MDg5MjgxNw==","name":"solidity","full_name":"ethereum/solidity","private":false,"owner":{"login":"ethereum","id":6250754,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYyNTA3NTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6250754?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ethereum/solidity","description":"Solidity, the Contract-Oriented Programming Language","fork":false,"url":"https://api.github.com/repos/ethereum/solidity","forks_url":"https://api.github.com/repos/ethereum/solidity/forks","keys_url":"https://api.github.com/repos/ethereum/solidity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/solidity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/solidity/teams","hooks_url":"https://api.github.com/repos/ethereum/solidity/hooks","issue_events_url":"https://api.github.com/repos/ethereum/solidity/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/solidity/events","assignees_url":"https://api.github.com/repos/ethereum/solidity/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/solidity/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/solidity/tags","blobs_url":"https://api.github.com/repos/ethereum/solidity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/solidity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/solidity/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/solidity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/solidity/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/solidity/languages","stargazers_url":"https://api.github.com/repos/ethereum/solidity/stargazers","contributors_url":"https://api.github.com/repos/ethereum/solidity/contributors","subscribers_url":"https://api.github.com/repos/ethereum/solidity/subscribers","subscription_url":"https://api.github.com/repos/ethereum/solidity/subscription","commits_url":"https://api.github.com/repos/ethereum/solidity/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/solidity/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/solidity/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/solidity/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereum/solidity/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/solidity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/solidity/merges","archive_url":"https://api.github.com/repos/ethereum/solidity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/solidity/downloads","issues_url":"https://api.github.com/repos/ethereum/solidity/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/solidity/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/solidity/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/solidity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/solidity/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/solidity/releases{/id}","deployments_url":"https://api.github.com/repos/ethereum/solidity/deployments","created_at":"2015-08-17T12:27:26Z","updated_at":"2019-02-11T17:08:18Z","pushed_at":"2019-02-11T17:30:29Z","git_url":"git://github.com/ethereum/solidity.git","ssh_url":"git@github.com:ethereum/solidity.git","clone_url":"https://github.com/ethereum/solidity.git","svn_url":"https://github.com/ethereum/solidity","homepage":"https://solidity.readthedocs.io","size":26041,"stargazers_count":6639,"watchers_count":6639,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1800,"mirror_url":null,"archived":false,"open_issues_count":590,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":1800,"open_issues":590,"watchers":6639,"default_branch":"develop"}},"base":{"label":"ethereum:develop","ref":"develop","sha":"49cd55d3a0b43eef47f1a61d346bd8f6d3407a83","user":{"login":"ethereum","id":6250754,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYyNTA3NTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6250754?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":40892817,"node_id":"MDEwOlJlcG9zaXRvcnk0MDg5MjgxNw==","name":"solidity","full_name":"ethereum/solidity","private":false,"owner":{"login":"ethereum","id":6250754,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYyNTA3NTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/6250754?v=4","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ethereum/solidity","description":"Solidity, the Contract-Oriented Programming Language","fork":false,"url":"https://api.github.com/repos/ethereum/solidity","forks_url":"https://api.github.com/repos/ethereum/solidity/forks","keys_url":"https://api.github.com/repos/ethereum/solidity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/solidity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/solidity/teams","hooks_url":"https://api.github.com/repos/ethereum/solidity/hooks","issue_events_url":"https://api.github.com/repos/ethereum/solidity/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/solidity/events","assignees_url":"https://api.github.com/repos/ethereum/solidity/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/solidity/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/solidity/tags","blobs_url":"https://api.github.com/repos/ethereum/solidity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/solidity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/solidity/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/solidity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/solidity/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/solidity/languages","stargazers_url":"https://api.github.com/repos/ethereum/solidity/stargazers","contributors_url":"https://api.github.com/repos/ethereum/solidity/contributors","subscribers_url":"https://api.github.com/repos/ethereum/solidity/subscribers","subscription_url":"https://api.github.com/repos/ethereum/solidity/subscription","commits_url":"https://api.github.com/repos/ethereum/solidity/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/solidity/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/solidity/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/solidity/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereum/solidity/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/solidity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/solidity/merges","archive_url":"https://api.github.com/repos/ethereum/solidity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/solidity/downloads","issues_url":"https://api.github.com/repos/ethereum/solidity/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/solidity/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/solidity/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/solidity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/solidity/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/solidity/releases{/id}","deployments_url":"https://api.github.com/repos/ethereum/solidity/deployments","created_at":"2015-08-17T12:27:26Z","updated_at":"2019-02-11T17:08:18Z","pushed_at":"2019-02-11T17:30:29Z","git_url":"git://github.com/ethereum/solidity.git","ssh_url":"git@github.com:ethereum/solidity.git","clone_url":"https://github.com/ethereum/solidity.git","svn_url":"https://github.com/ethereum/solidity","homepage":"https://solidity.readthedocs.io","size":26041,"stargazers_count":6639,"watchers_count":6639,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1800,"mirror_url":null,"archived":false,"open_issues_count":590,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":1800,"open_issues":590,"watchers":6639,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/5962"},"html":{"href":"https://github.com/ethereum/solidity/pull/5962"},"issue":{"href":"https://api.github.com/repos/ethereum/solidity/issues/5962"},"comments":{"href":"https://api.github.com/repos/ethereum/solidity/issues/5962/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/5962/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethereum/solidity/pulls/5962/commits"},"statuses":{"href":"https://api.github.com/repos/ethereum/solidity/statuses/799e2070af0b202bd13d9026e6d345459d48a538"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"leonardoalt"}}