-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
web3.eth.contract overhaul #199
Conversation
…ereum.js into develop Conflicts: dist/web3-light.js.map dist/web3-light.min.js dist/web3.js.map dist/web3.min.js
… into contract_overhaul
This is slightly tangential, but I think the API for calling contracts needs to be focused on the batch call scenario. Most non-trivial apps will be doing several function calls at a time, which can lead to a combinatorial explosion of calls when dealing with lists of objects that each have related lists of objects. I ended up adding async contract calls to Augur, but we're forced to minimize the concurrency to avoid choking geth at the network level with too many open sockets. We'll be able to ask for data sooner once we have a batch API available, though we've started using direct RPC calls instead of web3. I'm hoping that the lessons we learn will get rolled into web3 so all dapp builders can benefit, and so we can move back to web3 someday. |
I understand. And what do you think about following syntax for batch calls? contract.batch([
{name: myCall, params: [], options: {}, callback: cb},
{name: myCall1, params: [], options: {}, callback: cb},
{name: myCall2, params: [], options: {}, callback: cb},
{name: myTransact, params: [], options: {}, callback: cb}
]); or even something more general: var batch = web3.newBatch();
batch.add(contract.myCall.request(param1, {from: 0x...ff}, function (err, result) {}));
batch.add(contract.myTransact.request(param1, param2, {from: 0x...ff}, function (err, result) {}));
batch.add(web3.eth.getBalance.request(0x000..1f, function (err, result) {})
batch.add({jsonrpc: '2.0', method: 'eth_superMethod', params: 0x1231, callback: function (err, result) {} });
batch.execute() |
Please re-open with merge to develop not master |
Something like the second example is what I think would work best. I'm assuming that people are only going to want to batch calls, not transactions, so |
this pr contains new way of creating contract objects:
param1
,param2
...paramX
- contract constructor params (optional){code: 0x00...df}
- transaction object (required for methodnew
)function (err, contract) {}
- callback object (optional)there is also possibility to call && sendTransaction to contract asynchronously: