Home > Enterprise >  "transaction type not supported" When trying to deploy a simple contract using Go-Ethereum
"transaction type not supported" When trying to deploy a simple contract using Go-Ethereum

Time:11-14

When ever I try to deploy my smart contract to test, I receive an error indicating "transaction type not supported". Below is the source code. I'm trying to deploy my simple smart contract using abigen's Go bindings.

Versions:
go1.16.7
Solidity 0.8.9 commit.e5eed63a.Darwin.appleclang

Solidity Source code. I've tested this in Remix and it has worked everytime:

contract SendMSG {
    function Send(address sendTo, bytes calldata message) public {
        OtherContract other = OtherContract(sendTo);
        other.send(message);
    }
}

This is the contract I'm using ignore syntax errors as it may be human error while anonymizing.

I then run this line to develop the abi bindings and put them in the right place. I can confirm this works as the go file is always created: abigen --sol ../../contracts/Contract.sol --pkg Contract --out Contract.go

Go Code. I believe there shouldn't be any issues. I'm using a simulated backend/blockchain for testing:

package Contract
import (
    "testing"
    "github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
    "github.com/ethereum/go-ethereum/accounts/abi/bind"
    "github.com/ethereum/go-ethereum/crypto"
    "github.com/ethereum/go-ethereum/core"
    "github.com/ethereum/go-ethereum/common"
    "math/big"
)

// Test inbox contract gets deployed correctly
func TestMain(t *testing.T) {

    //Setup simulated block chain
    key, _ := crypto.GenerateKey()
    auth := bind.NewKeyedTransactor(key)

    alloc := make(core.GenesisAlloc)
    alloc[auth.From] = core.GenesisAccount{Balance: big.NewInt(133700000)}
    gasLimit := 300000
    sim := backends.NewSimulatedBackend(alloc, gasLimit)

    
    //Deploy contract
    address, _, _, err := DeploySameBindings(
        auth,
        sim,

    )
    // commit all pending transactions
    blockchain.Commit()
    
    if err != nil {
        t.Fatalf("Failed to deploy the contract: %v", err)
    }
}

Always, it gives the same err, "transaction type not supported". I know the line where the error origin [GitHub]. From there, maybe I didn't set a payment mechanism? But all the tutorials I've seen didn't include one and if anyone could provide a guide as to how to do that.

Thank you.

CodePudding user response:

This was stupid.

Geth updated their code and there weren't any tutorials so for anyone hoping to run a simulated background here's the answer:

You have to set the gas price manually. Taking this on after defining client and auth fixes it.

gasPrice, err := client.SuggestGasPrice(context.Background())
auth.GasPrice=gasPrice
  • Related