From e79dcc385d37eefb121f675d3800dbfe59b515c7 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Fri, 23 Nov 2018 12:12:10 +0800 Subject: api: allow sending batch of raw transactions --- ethclient/ethclient.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ethclient') diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 12eeaf0f6..c8a8e5eb5 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -506,6 +506,22 @@ func (ec *Client) SendTransaction(ctx context.Context, tx *types.Transaction) er return ec.c.CallContext(ctx, nil, "eth_sendRawTransaction", common.ToHex(data)) } +// SendTransactions injects a batch of signed transactions into the pending pool for execution. +// +// If a transaction was a contract creation use the TransactionReceipt method to get the +// contract address after the transaction has been mined. +func (ec *Client) SendTransactions(ctx context.Context, txs []*types.Transaction) error { + txData := make([]interface{}, len(txs)) + for i, tx := range txs { + data, err := rlp.EncodeToBytes(tx) + if err != nil { + return err + } + txData[i] = common.ToHex(data) + } + return ec.c.CallContext(ctx, nil, "eth_sendRawTransactions", txData) +} + func toCallArg(msg ethereum.CallMsg) interface{} { arg := map[string]interface{}{ "from": msg.From, -- cgit v1.2.3