I want to deploy contracts by using my go backend code with go-ethereum package. Since this part of the system will run as a central element (since it does a lot of other stuffs), I won't (and don't want to) access user's private keys. So, I want to deploy contracts that will be signed by users via metamask (my frontend + metamask browser extension).

According to this tutorial I could deploy my contracts, but it uses private key to sign it. Such as:

auth := bind.NewKeyedTransactor(privateKey) // Is NewClefTransactor that I should use?
auth.Nonce = big.NewInt(int64(nonce))
auth.Value = big.NewInt(0)     // in wei
auth.GasLimit = uint64(300000) // in units
auth.GasPrice = gasPrice

input := "1.0"
address, tx, instance, err := store.DeployStore(auth, client, input)
if err != nil {

Is it possible to deploy contract by using go, but signing them via MetaMask (browser)? (As I see external signers are not supported except clef)

Clarification: Users don't run local nodes, they only have access to a client-side frontend that served by the go backend, but I don't want the backend to access any private keys.

1 Answer 1


Basically you can -

  1. Pack the contract to deploy in your backend;
  2. Send the payload string to the frontend;
  3. MetaMask will pop to sign that data;
  4. Return a packed signed transaction to backend;
  5. Backend then sends this tx to geth.

Another option is that the frontend will be able to prepare the deployment payload itself, using ethers.js / web3 along with required ABI, etc. But I assume that in your case it would be easier to prepare payload on backend.

  • Thank you for your answer. In the end I stop at 3. and used ether's "sendTransaction", since when I used go-ethereum, It said "invalid sender". Probably I messed up the serialization, which is not straightforward at all. Thanks again.
    – prodx
    Commented May 6, 2022 at 20:32

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.