Last active
February 17, 2016 17:13
-
-
Save frozeman/8f0863a47568f6b1c5b6 to your computer and use it in GitHub Desktop.
New contract object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// un"addresses" contract object | |
var myContrac2 = new web3.eth.contract(abi) | |
myContrac2.address = '0x12345678...'; // add address later | |
// initiate with address | |
var myContrac = new web3.eth.contract(abi, address) | |
// deploy contract | |
eventemitter = new web3.eth.contract(abi).deploy(param1, {data: '0x23456'}); | |
eventEmitter.on('mined', function(err, address){ | |
new web3.eth.contract(abi, address); | |
}); | |
eventEmitter.on('transactionHash', function(err, hash){ | |
}); | |
new web3.eth.contract(abi).deploy.getData(param1, {data: '0x23456'}) | |
> 0x23456780000005345345 | |
// contract object events and methods | |
myContrac.call({from: '0x1234...'}).myMethod(param1 , cb) // calls cb with result | |
myContrac.transact({from: '0x1234...'}).myMethod(param1, cb) // calls cb with tx hash, in the future we could return a event transmitter | |
myContrac.getData.myMethod(param1) // get only the data of the call '0x23456787654323456765432340000000000000000000000034' |
The new keyword is necessary when creating a new instance, to make it clear that it is a new instance, imo:
var contract = new web3.eth.contract(abi, address);
Ah, not sure what I was thinking. new
looks good. 👍
Moved it to here: ethereum/EIPs#68
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
intersting idea, but the main problem is namespace problems, which i try to avoid. What if you name your contract event "mined"? then it would clash..