{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/EIPs/issues/68","repository_url":"https://api.github.com/repos/ethereum/EIPs","labels_url":"https://api.github.com/repos/ethereum/EIPs/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/EIPs/issues/68/comments","events_url":"https://api.github.com/repos/ethereum/EIPs/issues/68/events","html_url":"https://github.com/ethereum/EIPs/issues/68","id":134299925,"number":68,"title":"web3.js contract object re-design","user":{"login":"frozeman","id":232662,"avatar_url":"https://avatars.githubusercontent.com/u/232662?v=3","gravatar_id":"","url":"https://api.github.com/users/frozeman","html_url":"https://github.com/frozeman","followers_url":"https://api.github.com/users/frozeman/followers","following_url":"https://api.github.com/users/frozeman/following{/other_user}","gists_url":"https://api.github.com/users/frozeman/gists{/gist_id}","starred_url":"https://api.github.com/users/frozeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frozeman/subscriptions","organizations_url":"https://api.github.com/users/frozeman/orgs","repos_url":"https://api.github.com/users/frozeman/repos","events_url":"https://api.github.com/users/frozeman/events{/privacy}","received_events_url":"https://api.github.com/users/frozeman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ethereum/EIPs/labels/ERC","name":"ERC","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":47,"created_at":"2016-02-17T14:50:23Z","updated_at":"2016-07-14T23:28:45Z","closed_at":null,"body":"```\r\nERC: 68\r\nTitle: web3.js contract object re-design\r\nStatus: Draft\r\nType: Informational\r\nCreated: 08.01.2016\r\nResolution: https://github.com/ethereum/web3.js\r\n```\r\n# Abstract\r\n\r\nThis proposal is a move to make it a more future proof javascript representation of a ethereum smart contract.\r\n\r\n# Motivation\r\n\r\nThe contract object in web3.js in its current form has confused in many ways and has some draw backs, like not being able to pass a struct (object) as a functions arguments.\r\n\r\n# Usage\r\n\r\n```js\r\n// contract options can be\r\noptions = {\r\n    data: '0x12345678', // used when deploying contracts, so users don't need to pass in the data later\r\n    from: '0x12345678..', // default from when sending tx\r\n    gasPrice: '0xb', // default gasPrice when \r\n    gasLimit: '0xa' // default gasLimit when \r\n}\r\n\r\n\r\n// initiating an un\"addresses\" contract object\r\nvar myContract = new web3.eth.contract(abi [, options])\r\nmyContract.address = '0x12345678...'; // add address later\r\n\r\n// initiating with address\r\nvar myContract = new web3.eth.contract(abi, address [, options])\r\n\r\n// -> deploying a contract\r\neventemitter = myContract.deploy({\r\n    arguments: [param1, param2],\r\n    data: '0x2345678' // when provided, this is used over the one from the options object\r\n});\r\neventEmitter.on('error', function(error){ \r\n });\r\neventEmitter.on('transactionHash', function(hash){ \r\n });\r\neventEmitter.on('mined', function(address) { \r\n     new web3.eth.contract(abi, address);\r\n     // or\r\n    myContract.address = address;\r\n });\r\n// also promise style works, will be fired when mined\r\neventEmitter.then(function(address){\r\n}).catch(function(error){\r\n})\r\n\r\n// -> get the call data for a contract deployment\r\nmyContract.encodeABI({\r\n    method: 'constructor',\r\n    arguments: [param1, param2],\r\n    data: '0x2345678'\r\n});\r\n> 0x23456780000000000000000000005345345\r\n\r\n// -> events\r\nmyContract.on('someEvent' [, {filter: {myValue1: 23, myValue2: [3,5], ...}, fromBlock:..}], function(error, returnValues, log) {})\r\n\r\nmyContract.pastEvents(('someEvent' [, {filter: {myValue1: 23, myValue2: [3,5], ...}, fromBlock:.., toBlock: ...}], function(error, returnValues, log) {\r\n   // called for every past event.\r\n});\r\n\r\n// if a `filter` option is provided, it means either value can be contained in the matching event (log)\r\n\r\n// -> methods\r\nmyContract.estimateGas({from: '0x1234...'}).myMethod(param1 , function(error, result){}) // calls cb with result, also returns eventifiedPromise with event \"return\"\r\n\r\nmyContract.call({from: '0x1234...'}).myMethod(param1 , function(error, result){}) // calls cb with result, also returns eventifiedPromise with event \"return\"\r\n\r\nmyContract.transact({from: '0x1234...'}).myMethod(param1, function(error, hash){}) // calls cb with tx hash\r\n\r\nvar eventEmitter  = myContract.transact({from: '0x1234...'}).myMethod(param1) // calls without cb return eventEmitter\r\neventEmitter.on('error', function(error){ \r\n });\r\neventEmitter.on('transactionHash', function(hash){ \r\n });\r\neventEmitter.on('mined', function(receipt) { \r\n });\r\n// also promise style works, will be fired when mined\r\neventEmitter.then(function(hash){\r\n}).catch(function(error){\r\n})\r\n\r\n// -> get the abi of a method\r\nmyContract.encodeABI({\r\n    method: 'myMethod',\r\n    arguments: ['hello', 12345] \r\n}) // get only the data of the call '0x23456787654323456765432340000000000000000000000034'\r\n```\r\n\r\n# Summary\r\n\r\nThe contract object would then look as follow:\r\n```js\r\nnew web3.eth.contract(abi, address);\r\n> {\r\n   address: '0x123456...',\r\n   deploy: function(options){...},\r\n   encodeABI: function(options){...},\r\n   // events\r\n   on: function(event, options, callback){...},\r\n   pastEvents:  function(event, options, callback){...},\r\n   // methods\r\n   estimateGas: function(options){...},\r\n   call: function(options){...},\r\n   transact: function(options){...}\r\n}\r\n```\r\n\r\n# Community Request\r\n\r\nPlease give comments and reasons, why we should go in one way or another. **Please lets keep this ERC short, We don't want to spend multiple weeks discussing this ;)**"},"comment":{"url":"https://api.github.com/repos/ethereum/EIPs/issues/comments/232821555","html_url":"https://github.com/ethereum/EIPs/issues/68#issuecomment-232821555","issue_url":"https://api.github.com/repos/ethereum/EIPs/issues/68","id":232821555,"user":{"login":"aakilfernandes","id":1577353,"avatar_url":"https://avatars.githubusercontent.com/u/1577353?v=3","gravatar_id":"","url":"https://api.github.com/users/aakilfernandes","html_url":"https://github.com/aakilfernandes","followers_url":"https://api.github.com/users/aakilfernandes/followers","following_url":"https://api.github.com/users/aakilfernandes/following{/other_user}","gists_url":"https://api.github.com/users/aakilfernandes/gists{/gist_id}","starred_url":"https://api.github.com/users/aakilfernandes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aakilfernandes/subscriptions","organizations_url":"https://api.github.com/users/aakilfernandes/orgs","repos_url":"https://api.github.com/users/aakilfernandes/repos","events_url":"https://api.github.com/users/aakilfernandes/events{/privacy}","received_events_url":"https://api.github.com/users/aakilfernandes/received_events","type":"User","site_admin":false},"created_at":"2016-07-14T23:28:45Z","updated_at":"2016-07-14T23:28:45Z","body":"@Schaeff There's this https://github.com/SafeMarket/web3-q but it wraps the default web3 functions for upgrade reasons."}}
{"actor":{"display_login":"aakilfernandes"}}