I am trying to create a raw EIP-1559 transaction using the DynamicFeeTx method since I want to provide a gas tip cap. When I create this raw transaction, sign it and encode it using rlp, I get a raw transaction that is invalid when I use https://www.ethereumdecoder.com/ to validate it. Here is my golang code:

    tx := types.NewTx(&types.DynamicFeeTx{
        Nonce:     nonce,
        GasFeeCap: gasFeeCap,
        GasTipCap: gasTipCap,
        Gas:       uint64(gasUsed),
        To:        &toAddress,
        Value:     new(big.Int),
        Data:      []byte(calldata),
        ChainID:   chainID,

    signedTx, err := types.SignTx(tx, types.LatestSignerForChainID(chainID), model.TRANSACTION_PRIVATE_KEY_ECDSA)
    if err != nil {
        return "", err

    rawTxBytes, err := rlp.EncodeToBytes(signedTx)
    if err != nil {
        return "", err

    rawTxHex := hex.EncodeToString(rawTxBytes)

    return fmt.Sprintf("0x%s", rawTxHex)

What is suprising is that if I use the old method and create the tx like so:

tx := types.NewTransaction(nonce, toAddress, new(big.Int), uint64(gasUsed), gasFeeCap, []byte(calldata))

Then it creates a raw transaction, which after encoding and hexifying, is valid using the ethereumdecoder link from above.

Am I missing a step? Is there a good guide I can follow that shows how to create and encode DynamicFeeTx transactions?

Thank you in advance

1 Answer 1


I believe I found the issue. For a DynamicFeeTx rlp should not be used, should use signedTx.MarshalBinary()

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.