@@ -76,6 +76,10 @@ type SendTxArgs struct {
7676 // We accept "data" and "input" for backwards-compatibility reasons.
7777 Data * hexutil.Bytes `json:"data"`
7878 Input * hexutil.Bytes `json:"input,omitempty"`
79+
80+ // For non-legacy transactions
81+ AccessList * types.AccessList `json:"accessList,omitempty"`
82+ ChainID * hexutil.Big `json:"chainId,omitempty"`
7983}
8084
8185func (args SendTxArgs ) String () string {
@@ -93,8 +97,32 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
9397 } else if args .Input != nil {
9498 input = * args .Input
9599 }
96- if args .To == nil {
97- return types .NewContractCreation (uint64 (args .Nonce ), (* big .Int )(& args .Value ), uint64 (args .Gas ), (* big .Int )(& args .GasPrice ), input )
100+ var to * common.Address
101+ if args .To != nil {
102+ _to := args .To .Address ()
103+ to = & _to
104+ }
105+ var data types.TxData
106+ if args .AccessList == nil {
107+ data = & types.LegacyTx {
108+ To : to ,
109+ Nonce : uint64 (args .Nonce ),
110+ Gas : uint64 (args .Gas ),
111+ GasPrice : (* big .Int )(& args .GasPrice ),
112+ Value : (* big .Int )(& args .Value ),
113+ Data : input ,
114+ }
115+ } else {
116+ data = & types.AccessListTx {
117+ To : to ,
118+ ChainID : (* big .Int )(args .ChainID ),
119+ Nonce : uint64 (args .Nonce ),
120+ Gas : uint64 (args .Gas ),
121+ GasPrice : (* big .Int )(& args .GasPrice ),
122+ Value : (* big .Int )(& args .Value ),
123+ Data : input ,
124+ AccessList : * args .AccessList ,
125+ }
98126 }
99- return types .NewTransaction ( uint64 ( args . Nonce ), args . To . Address (), ( * big . Int )( & args . Value ), ( uint64 )( args . Gas ), ( * big . Int )( & args . GasPrice ), input )
127+ return types .NewTx ( data )
100128}
0 commit comments