umbracle/ethgo

How to send EIP1559 transction?

dingding001 opened this issue · 1 comments

Type:0 is OK, Type:2 error

According to structs_marshal_rlp.go:MarshalRLPWith function

I add: Type, ChainID,MaxPriorityFeePerGas,MaxFeePerGas, delete GasPrice,

result:
{"code":-32000,"message":"invalid sender"}

//---------test---------------------------

web3 "github.com/umbracle/ethgo"

txn := &web3.Transaction{
To: &conAddr,
Value:big.NewInt(0),
//GasPrice: gasPrice,
Gas:90000,
Nonce:nonce,
Input:data,
Type:web3.TransactionDynamicFee, //2
ChainID: new(big.Int).SetInt64(137), //
MaxPriorityFeePerGas:new(big.Int).SetInt64(35000000000), // 35Gwei
MaxFeePerGas: new(big.Int).SetInt64(100000000000)} // 100Gwei

signer := wallet.NewEIP155Signer(137)
txn, _ = signer.SignTx(txn, key)

//LogStruct(&txn)
//sendData := txn.MarshalRLP()
sendData,err := txn.MarshalRLPTo(nil)
if(err != nil){
	fmt.Println(err)
	return
}

hash, err := Client.Eth().SendRawTransaction(sendData)
if(err != nil){
	fmt.Println(err)
	return
}
fmt.Println(hash)

Initial approach in #198