Skip to content

Commit c55e1b4

Browse files
committed
ethapi: implement filltransaction
1 parent aa6005b commit c55e1b4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

internal/ethapi/api.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,22 @@ func (s *PublicTransactionPoolAPI) SendTransaction(ctx context.Context, args Sen
14411441
return SubmitTransaction(ctx, s.b, signed)
14421442
}
14431443

1444+
// FillTransaction fills the defaults (nonce, gas, gasPrice) on a given unsigned transaction,
1445+
// and returns it to the caller for further processing (signing + broadcast)
1446+
func (s *PublicTransactionPoolAPI) FillTransaction(ctx context.Context, args SendTxArgs) (*SignTransactionResult, error) {
1447+
// Set some sanity defaults and terminate on failure
1448+
if err := args.setDefaults(ctx, s.b); err != nil {
1449+
return nil, err
1450+
}
1451+
// Assemble the transaction and obtain rlp
1452+
tx := args.toTransaction()
1453+
data, err := rlp.EncodeToBytes(tx)
1454+
if err != nil {
1455+
return nil, err
1456+
}
1457+
return &SignTransactionResult{data, tx}, nil
1458+
}
1459+
14441460
// SendRawTransaction will add the signed transaction to the transaction pool.
14451461
// The sender is responsible for signing the transaction and using the correct nonce.
14461462
func (s *PublicTransactionPoolAPI) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) {

internal/web3ext/web3ext.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,12 @@ web3._extend({
483483
params: 1,
484484
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
485485
}),
486+
new web3._extend.Method({
487+
name: 'fillTransaction',
488+
call: 'eth_fillTransaction',
489+
params: 1,
490+
inputFormatter: [web3._extend.formatters.inputTransactionFormatter]
491+
}),
486492
new web3._extend.Method({
487493
name: 'getHeaderByNumber',
488494
call: 'eth_getHeaderByNumber',

0 commit comments

Comments
 (0)