0

I'm running a private Ethereum blockchain on my computer. I've installed Metamask on my chrome as well.

I can create an account on metamask, and then interact with my smart contract deployed on my private blockchain. It works fine. Also, everything works fine when I use remix to interact with my smart contract on my private blockchain.

I'm designing my own local HTML file. My HTML file can interact with the smart contract, in the sense that it can read the contract's state.

But when I want to call a function that changes the contract state, I get this error on my HTML file:

Uncaught Error: unknown account
at Object.InvalidResponse (web3.min.js:1)
at s.send (web3.min.js:1)
at _.e [as sendTransaction] (web3.min.js:1)
at c.sendTransaction (web3.min.js:1)
at register_std_num (tt.html:413) // this is the function (in my contract) I want to call 
at HTMLButtonElement.onclick (tt.html:20)

Also, I have tried both:

 myContract.register_std_num.sendTransaction(stud_num,{from: "0x333333",gas:4200000});

and

myContract.register_std_num(stud_num,{from: "0x333333",gas:4200000});

where "0x333333" is the address I have created in Metamask.

Note that when I click the related button in the HTML file, MetamasK is not invoked.

Question: Which part am I missing? Is there anything else I need to do?

Please note that, in my HTML file, if I use an account I have created in geth, then I unlock the account and send the same transaction with that account, I can see that the transaction is sent to the blockchain. But as I said above, it does not work with the account I have created in Metamask.

  • What private network is it? What does it mean that 0x333333 be a valid Ethereum account? – Rick Park Jan 17 at 16:52
  • @ Rick Park Thanks for your comment! it's an Ethereum private blockchain and I'm using my local network: 8545. The address I stated in the question: 0x333333 is just an example as I wanted to avoid using a long address. But in practice, it's a long valid address. – Ay. Jan 17 at 17:07
  • Are you able to send funds from and to 0x333333 and the account you created in Geth? – Rick Park Jan 17 at 17:34
  • @Rick Park Yes I can send funds from MetaMask address via metamask add on on Chrome. also, I can send funds from geth account to MEtamask address via command line. – Ay. Jan 17 at 17:37
  • I understood. I mean: are you able to send funds (to and from) between a working address on Geth (see your last edit) AND one account, not working, you created by metamask? I called it “0x333333” following your notes – Rick Park Jan 17 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.