diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-11-23 12:12:10 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:54 +0800 |
commit | e79dcc385d37eefb121f675d3800dbfe59b515c7 (patch) | |
tree | 220cd446864dcca990d1adeafd23fe7e301ced7e /ethclient | |
parent | c51c2a240cd3f01bf8bdb6a1644a902b2335b2aa (diff) | |
download | dexon-e79dcc385d37eefb121f675d3800dbfe59b515c7.tar dexon-e79dcc385d37eefb121f675d3800dbfe59b515c7.tar.gz dexon-e79dcc385d37eefb121f675d3800dbfe59b515c7.tar.bz2 dexon-e79dcc385d37eefb121f675d3800dbfe59b515c7.tar.lz dexon-e79dcc385d37eefb121f675d3800dbfe59b515c7.tar.xz dexon-e79dcc385d37eefb121f675d3800dbfe59b515c7.tar.zst dexon-e79dcc385d37eefb121f675d3800dbfe59b515c7.zip |
api: allow sending batch of raw transactions
Diffstat (limited to 'ethclient')
-rw-r--r-- | ethclient/ethclient.go | 16 |
1 files changed, 16 insertions, 0 deletions
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, |