I have managed to get a hooked web3 provider with eth-lightwallet creating a contract on a private geth node. I see the tx on the geth logs and see it get added to a block when mined.
However I am not getting the contract.address returned in the callback. I get the transaction hash. My gut feeling tells me there are two steps happening underneath: the tx hash is provided in the JSON RPC response underneath but a corresponding eth_getTransactionReceipt is not being done or processes before comingback to the callback.
Help appreciated.
var ethClient = "http://localhost:1234";
var web3 = new Web3();
var global_keystore;
// setting up a web3 provider but using a keystore to get access to account information
function setWeb3Provider(keystore) {
var web3Provider = new HookedWeb3Provider({
host: ethClient,
transaction_signer: keystore
});
web3.setProvider(web3Provider);
}
// .....
var password = prompt('Enter Password to encrypt your seed', 'Password');
var providedSeed = document.getElementById('seed').value;
lightwallet.keystore.deriveKeyFromPassword(password, function (err, pwDerivedKey) {
global_keystore = new lightwallet.keystore(
providedSeed,
pwDerivedKey);
global_keystore.generateNewAddress(pwDerivedKey, 2);
setWeb3Provider(global_keystore);
// .... important bit....
var contract = web3.eth.contract(_contractABI);
var myContract = contract.new(
{
from: _ethWalletAddress,
data: _contractCode,
gas: 3000000,
gasPrice: 18000000010
}, function(e, contract){
console.log("error object: " + e );
console.log("contract object: " + contract);
if (typeof contract != 'undefined') {
console.log('address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
});
}
});
Example of logs from a private geth network:
I0424 13:28:13.816421 eth/api.go:1177] Tx(3645d30afa7923cca42359dc2d1e46084f0da11f0b5476111a1e2ac7a82eb56f) created: 0746c6c2fde77b607e83e2bb6c25f919817e8459
I0424 13:28:23.028763 miner/miner.go:119] Starting mining operation (CPU=8 TOT=9)
I0424 13:28:23.036100 miner/worker.go:565] commit new work on block 4446 with 1 txs & 1 uncles. Took 7.286103ms
and the result of a manual getTransactionReceipt with JSON RPC:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x3645d30afa7923cca42359dc2d1e46084f0da11f0b5476111a1e2ac7a82eb56f"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x3a524c681be27a65d6058e54de35e5502d8353e85b7a5b013c86a6909eb63dd3","blockNumber":"0x115e","contractAddress":"0x0746c6c2fde77b607e83e2bb6c25f919817e8459","cumulativeGasUsed":"0x101716","from":"0xa57f54760210a39a376231bd20d5fcec4eaf75fa","gasUsed":"0x101716","logs":[],"root":"38789ca516316c1303eda94b690202875a77d66e3116f8733081197f7157f093","to":null,"transactionHash":"0x3645d30afa7923cca42359dc2d1e46084f0da11f0b5476111a1e2ac7a82eb56f","transactionIndex":"0x0"}}
ps. I don't know what the log report 1 uncle. Other contract creation logs didn't report any uncles but all exhibit the same issue with the callback.