I was using Nethereum for one of my application, there I found I have to sign transaction before calling a smart contract method, which was OK. I was using infura api.

When I was calling SendTransactionAsync() . There was an error occured

eth_sendTransaction does not exist/is not available

I found a solution to use Private key and get signed account

IAccount account = new Account(privateKey);

But i am not happy with this solution, I don't want deal with someone's private key in my Code.

Is there any alternative solution? and Please tell me is it a good idea or ok to use private key in your code?

1 Answer 1


If you want to sign and send a transaction, you have to use a private key. That's one of they key features of blockchains: one private key represents one public address, so when you sign a transaction with a private key, everyone can trust that the key's public address is yours. There is no way to send a transaction without a private key.

Of course you should manage private keys very carefully in your code. Depending on your setup, you should store the key in some secure place and access it only when needed.

  • Thanks for your answer, but i have a concern that I can store that private key somewhere and do vulnerable things. Why a user would trust me if i can decrypt or found his private key? Jun 24, 2021 at 5:46
  • 1
    You usually shouldn't handle users' private keys, only your own. Typically users keep their own keys and "login" to a system with something like MetaMask - that way your system never sees the private key. Jun 24, 2021 at 5:47
  • I used React.js and web3 there metamask extension of chrome does the jobs for me. But in case of backend developed with nethereum,a user will call my Nethrereum api after that authentication via metamask from the frontend app? thats how can it be done? Jun 24, 2021 at 5:52
  • As a general rule, if your backend has to do transactions on its own, it needs its own private key. The backend shouldn't typically send transactions on behalf of a user, so all the user interaction happens in the frontend. If you have further questions, please post a new question Jun 24, 2021 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.