0

We have a private Ethereum network running in our testbed. And a web3j-based (Java) API exposes various functionalities to the deployed smart contracts on the blockchain. The API connects to the blockchain using its own Ethereum identity/credentials.

A frontend application (under development) will be interacting with the blockchain via the web3j-based API. We might also use Metamask for user wallet management at the frontend app.

Our current concern is that all the transactions currently fired to the Ethereum blockchain are sent using the API's identity (msg.sender or tx.origin within the smart contracts). Is there a way where the end user doesn't have to pass on their credentials to the API but just authenticate/authorize/sign the transactions and the API can submit the transactions on the user's behalf to the Ethereum blockchain?

We're very new in this direction and would appreciate any help.
Thank you in advance!

0

When sending transactions into the ethereum network, you have to sign the transaction, a not signed transaction is not accepted. The signing is done via private keys, held inside your network gateway node (ethereum node).

So if you use web3, it will contact the ethereum node via an RPC (TCP) API and ask to sign the transaction by the user private key related to a given address. Private keys usage is protected by password, so you will have to unlock, by supplying the password, it for usage (web3.unlockAccount()) before sending any transaction.

TLDR : You will always have to pass private credentials to be able to send transactions. A possible solution to your problem is to create an auxiliary user system that you manage by smart contract.

Explanation

What I meant with "an auxiliary user system" is a basic user management system, available on any platform, that doesn't use, as basis, the ethereum user and account system. So basically, create a standalone platform and make a link between the users on your platform and the user and account on the ethereum platform**.

An other thing I meant is to use a single user (address) when interacting with the ethereum platform. this address should belong to the platform and should be used to interact with a smart contract.

**The smart contract will manage these new types of accounts ( an account struct with an attribute storing an ethereum address).

  • Could you please elaborate on "A possible solution to your problem is to create an auxiliary user system that you manage by smart contract"? Any pointers for the same will also be very helpful. – B Sameer Kumar Subudhi Aug 13 '18 at 9:12
  • @BSameerKumarSubudhi check my answer again. – Kaki Master Of Time Aug 14 '18 at 18:12
0

You can just have the user sign the transaction via Metamask without submitting the transaction and just get that transaction in the dapp. Then you can send the transaction to your webj based API. If this is all through your private blockchain, then you can just set the fees to nothing if you don't need them to have eth in their account.

Your Answer

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

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