Geth version: geth version
Version: 1.6.6-unstable. go version is : go1.9beta2 windows/amd64
OS & Version: Windows/Linux/OSX
win10
Commit hash : (if develop)
I use the old method to deploy the smart contract, but it shows error.I write a smart contract below and compile it on Remix online IDE.
pragma solidity ^0.4.0;
////////////////////////////////////////////////////////////
// This is an password contract which inclued new,verify,delete,change password
// it also includes the user here.
////////////////////////////////////////////////////////////
contract userPasswd
{
mapping(bytes32 => bytes32) private userPasswds ;
event RecordReturnResult(bool res);
/// @dev new the pair of user and password to the array here
function newPair(string user, string password) returns (bool) {
bytes32 sha3_user = sha3(user);
bytes32 sha3_password = sha3(password);
bool res = true;
if (userPasswds[sha3_user] > 0) {
res = false;
RecordReturnResult(res);
return res;
}
else{
userPasswds[sha3_user] = sha3_password;
res = true;
RecordReturnResult(res);
return res;
}
}
/// @dev verify the pair of user and password stored in the blockchain
function verify(string user, string password) returns (bool) {
bytes32 sha3_user = sha3(user);
bytes32 sha3_password = sha3(password);
//userPasswd[sha3_user] = sha3_password;
//check it
if (userPasswds[sha3_user] == sha3_password){
RecordReturnResult(true);
return true;
}
else{
RecordReturnResult(false);
return false;
}
}
/// @dev delete the pair of user and password stored in the blockchain
function del(string user) returns (bool) {
bytes32 sha3_user = sha3(user);
if (userPasswds[sha3_user] > 0){
delete userPasswds[sha3_user];
RecordReturnResult(true);
return true;
}
else {
RecordReturnResult(false);
return false;
}
}
/// @dev change the pair of user and password stored in the blockchain
function change(string user, string password) returns (bool) {
bytes32 sha3_user = sha3(user);
bytes32 sha3_password = sha3(password);
if (userPasswds[sha3_user] > 0){
userPasswds[sha3_user] = sha3_password;
RecordReturnResult(true);
return true;
}
else {
RecordReturnResult(false);
return false;
}
}
}
After compiling in Remix. I copy the content of (the “Web3 deploy” text box) and paste it into the geth console. the content of the “Web3 deploy” text box is :
var browser_queue_sol_userpasswdContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"user","type":"string"},{"name":"password","type":"string"}],"name":"newPair","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"user","type":"string"}],"name":"del","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"user","type":"string"},{"name":"password","type":"string"}],"name":"change","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"user","type":"string"},{"name":"password","type":"string"}],"name":"verify","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"res","type":"bool"}],"name":"RecordReturnResult","type":"event"}]);
var browser_queue_sol_userpasswd = browser_queue_sol_userpasswdContract.new(
{
from: web3.eth.accounts[0],
data: '0x6060604052341561000c57fe5b5b61094c8061001c6000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063021df6f41461005c5780630bca089a1461011157806383841e0c146101835780639deb17f514610238575bfe5b341561006457fe5b6100f7600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506102ed565b604051808215151515815260200191505060405180910390f35b341561011957fe5b610169600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506104a6565b604051808215151515815260200191505060405180910390f35b341561018b57fe5b61021e600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506105e8565b604051808215151515815260200191505060405180910390f35b341561024057fe5b6102d3600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091905050610796565b604051808215151515815260200191505060405180910390f35b6000600060006000856040518082805190602001908083835b602083106103295780518252602082019150602081019050602083039250610306565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390209250846040518082805190602001908083835b6020831061038c5780518252602082019150602081019050602083039250610369565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902091506001905060006001026000600085600019166000191681526020019081526020016000205460001916111561043157600090507fefe8ebaf9ed2e16504b843d837b30a57a2ece6b4bed1598ecd1cf4d0cc46b23181604051808215151515815260200191505060405180910390a180935061049d565b816000600085600019166000191681526020019081526020016000208160001916905550600190507fefe8ebaf9ed2e16504b843d837b30a57a2ece6b4bed1598ecd1cf4d0cc46b23181604051808215151515815260200191505060405180910390a180935061049d565b5b50505092915050565b60006000826040518082805190602001908083835b602083106104de57805182526020820191506020810190506020830392506104bb565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020905060006001026000600083600019166000191681526020019081526020016000205460001916111561059c57600060008260001916600019168152602001908152602001600020600090557fefe8ebaf9ed2e16504b843d837b30a57a2ece6b4bed1598ecd1cf4d0cc46b2316001604051808215151515815260200191505060405180910390a1600191506105e2565b7fefe8ebaf9ed2e16504b843d837b30a57a2ece6b4bed1598ecd1cf4d0cc46b2316000604051808215151515815260200191505060405180910390a1600091506105e2565b5b50919050565b600060006000846040518082805190602001908083835b6020831061062257805182526020820191506020810190506020830392506105ff565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390209150836040518082805190602001908083835b602083106106855780518252602082019150602081019050602083039250610662565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390209050600060010260006000846000191660001916815260200190815260200160002054600019161115610748578060006000846000191660001916815260200190815260200160002081600019169055507fefe8ebaf9ed2e16504b843d837b30a57a2ece6b4bed1598ecd1cf4d0cc46b2316001604051808215151515815260200191505060405180910390a16001925061078e565b7fefe8ebaf9ed2e16504b843d837b30a57a2ece6b4bed1598ecd1cf4d0cc46b2316000604051808215151515815260200191505060405180910390a16000925061078e565b5b505092915050565b600060006000846040518082805190602001908083835b602083106107d057805182526020820191506020810190506020830392506107ad565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390209150836040518082805190602001908083835b602083106108335780518252602082019150602081019050602083039250610810565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902090508060001916600060008460001916600019168152602001908152602001600020546000191614156108d2577fefe8ebaf9ed2e16504b843d837b30a57a2ece6b4bed1598ecd1cf4d0cc46b2316001604051808215151515815260200191505060405180910390a160019250610918565b7fefe8ebaf9ed2e16504b843d837b30a57a2ece6b4bed1598ecd1cf4d0cc46b2316000604051808215151515815260200191505060405180910390a160009250610918565b5b5050929150505600a165627a7a72305820d4dc1814f8019a55e6804ed1edd56a9b9063de8ef06dc0922e2af422094a0c770029',
gas: '400000'
}, function (e, contract){
console.log(e, contract);
if (typeof contract.address !== 'undefined') {
console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
}
})
and the console shows:Error: invalid sender undefined
undefined
the geth version is: Version: 1.6.6-unstable. go version is : go1.9beta2 windows/amd64
Can anybody help me ? thank you
there is eth.accounts[0], and hava enough gas of accounts[0]
It does seem that web3.eth.accounts[0] returned undefined. Are you sure it works if you type that in the console?
thank you very much.web3.eth.accounts[0] seems works well, the result is below:
> personal.unlockAccount(eth.accounts[0], '123456', 1000)
true
> var browser_queue_sol_queueContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"d","type":"uint256"}],"name":"addRequest","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"queueLength","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"popRequest","outputs":[],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_element","type":"uint256"}],"name":"ElementPopped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_element","type":"uint256"},{"indexed":false,"name":"_index","type":"uint256"}],"name":"ElementPushed","type":"event"}]);
undefined
> var browser_queue_sol_queue = browser_queue_sol_queueContract.new(
... {
...... from: web3.eth.accounts[0],
...... data: '0x6060604052341561000c57fe5b5b60c860006000018161001f9190610026565b505b610077565b81548183558181151161004d5781836000526020600020918201910161004c9190610052565b5b505050565b61007491905b80821115610070576000816000905550600101610058565b5090565b90565b6102b0806100866000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634ca1fad814610051578063ab91c7b014610071578063e4690a0b14610097575bfe5b341561005957fe5b61006f60048080359060200190919050506100a9565b005b341561007957fe5b6100816100b8565b6040518082815260200191505060405180910390f35b341561009f57fe5b6100a76100ca565b005b6100b460008261010d565b5b50565b60006100c460006101b4565b90505b90565b7fe32433683389a476fe90f93c07386d118310387cc5442554f0f6c2cc839c59426100f560006101c9565b6040518082815260200191505060405180910390a15b565b6101168261025a565b156101215760006000fd5b8082600001836002015481548110151561013757fe5b906000526020600020900160005b50819055507fef848106789acd461bcac88ec81e355ecd41e4be7d7491a567cca53a6cbcec96818360020154604051808381526020018281526020019250505060405180910390a1816000018054905060018360020154018115156101a657fe5b0682600201819055505b5050565b6000816001015482600201540390505b919050565b60008160010154826002015414156101e057610255565b8160000182600101548154811015156101f557fe5b906000526020600020900160005b5054905081600001826001015481548110151561021c57fe5b906000526020600020900160005b50600090558160000180549050600183600101540181151561024857fe5b0682600101819055508090505b919050565b600081600101548260000180549050600184600201540181151561027a57fe5b061490505b9190505600a165627a7a723058202bf2e05f5b798836d525200eda8f26ec77b1773fb691c8877b80de58e03867910029',
...... gas: '470000'
...... }, function (e, contract){
...... console.log(e, contract);
...... if (typeof contract.address !== 'undefined') {
......... console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
......... }
...... })
Error: invalid sender undefined
undefined
> web3.eth.accounts[0]
"0x72b1897d547548148dae04813cb4920d3c66810f"
>
I am very puzzled about the question here.
I replace web3.eth.accounts[0] to '0x0f5eebe8894683f1a8757ce570a481d3bf563ac6' which is web3.eth.accounts[0], but it still shows the same error.
> var browser_queue_sol_queue = browser_queue_sol_queueContract.new(
... {
...... from: "0x72b1897d547548148dae04813cb4920d3c66810f",
...... data: '0x6060604052341561000c57fe5b5b60c860006000018161001f9190610026565b505b610077565b81548183558181151161004d5781836000526020600020918201910161004c9190610052565b5b505050565b61007491905b80821115610070576000816000905550600101610058565b5090565b90565b6102b0806100866000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634ca1fad814610051578063ab91c7b014610071578063e4690a0b14610097575bfe5b341561005957fe5b61006f60048080359060200190919050506100a9565b005b341561007957fe5b6100816100b8565b6040518082815260200191505060405180910390f35b341561009f57fe5b6100a76100ca565b005b6100b460008261010d565b5b50565b60006100c460006101b4565b90505b90565b7fe32433683389a476fe90f93c07386d118310387cc5442554f0f6c2cc839c59426100f560006101c9565b6040518082815260200191505060405180910390a15b565b6101168261025a565b156101215760006000fd5b8082600001836002015481548110151561013757fe5b906000526020600020900160005b50819055507fef848106789acd461bcac88ec81e355ecd41e4be7d7491a567cca53a6cbcec96818360020154604051808381526020018281526020019250505060405180910390a1816000018054905060018360020154018115156101a657fe5b0682600201819055505b5050565b6000816001015482600201540390505b919050565b60008160010154826002015414156101e057610255565b8160000182600101548154811015156101f557fe5b906000526020600020900160005b5054905081600001826001015481548110151561021c57fe5b906000526020600020900160005b50600090558160000180549050600183600101540181151561024857fe5b0682600101819055508090505b919050565b600081600101548260000180549050600184600201540181151561027a57fe5b061490505b9190505600a165627a7a723058202bf2e05f5b798836d525200eda8f26ec77b1773fb691c8877b80de58e03867910029',
...... gas: '470000'
...... }, function (e, contract){
...... console.log(e, contract);
...... if (typeof contract.address !== 'undefined') {
......... console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
......... }
...... })
Error: invalid sender undefined
undefined
>
by the way: I am in Win10.
but it aloways shows
> eth.getBalanWARN [07-11|09:59:16] System clock seems off by -14.776174992s, which can prevent network connectivity
WARN [07-11|09:59:16] Please enable network time synchronisation in system settings.
afterwards so it is not the primary cause, I have solved the time synchronisation problem, but it still shows : invalid sender undefined after pasting contract to console.
geth.exe --identity "helloworld" --ws --wsaddr 10.0.49.2 --wsport 8546 --wsorigins="" --rpc --rpcaddr 10.0.49.2 --rpcport 8545 --rpccorsdomain "" --datadir "C:\tools\src\github.com\ethereum\go-ethereum\ethereum" --port 30303 --rpcapi "db,eth,net,ssh,miner,web3,personal,admin" --cache 2048 --networkid 88888 console it is command run geth.
{ "config": { "chainId": 0, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0 }, "alloc" : {}, "coinbase" : "0x0000000000000000000000000000000000000000", "difficulty" : "0x1", "extraData" : "", "gasLimit" : "0x2fefd8", "nonce" : "0x0000000000000042", "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp" : "0x00" } it is genesis.json
can some body help me?
I got same error :)
I changed my genesis.json and fixed the error.
"chainId": 0 -> "chainId": 10
But I don't know why.
I got the the same and have fixed this by changing the chainId from "0" to "15"
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
I changed my genesis.json and fixed the error.
"chainId": 0 -> "chainId": 10
But I don't know why.