diff --git a/pkg/relay/ethereum/client.go b/pkg/relay/ethereum/client.go index 4ae89c2..0df5e89 100644 --- a/pkg/relay/ethereum/client.go +++ b/pkg/relay/ethereum/client.go @@ -18,13 +18,25 @@ func (chain *Chain) CallOpts(ctx context.Context, height int64) *bind.CallOpts { return opts } -func (chain *Chain) TxOpts(ctx context.Context) (*bind.TransactOpts, error) { +func (chain *Chain) TxOpts(ctx context.Context, useLatestNonce bool) (*bind.TransactOpts, error) { + addr := chain.signer.Address() + txOpts := &bind.TransactOpts{ - From: chain.signer.Address(), + From: addr, Signer: chain.signer.Sign, } + if err := NewGasFeeCalculator(chain.client, &chain.config).Apply(ctx, txOpts); err != nil { return nil, err } + + if useLatestNonce { + if nonce, err := chain.client.NonceAt(ctx, addr, nil); err != nil { + return nil, err + } else { + txOpts.Nonce = new(big.Int).SetUint64(nonce) + } + } + return txOpts, nil } diff --git a/pkg/relay/ethereum/tx.go b/pkg/relay/ethereum/tx.go index ffb58e2..9d96c5b 100644 --- a/pkg/relay/ethereum/tx.go +++ b/pkg/relay/ethereum/tx.go @@ -41,7 +41,7 @@ func (c *Chain) SendMsgs(msgs []sdk.Msg) ([]core.MsgID, error) { logAttrMsgType, fmt.Sprintf("%T", msg), )} - opts, err := c.TxOpts(ctx) + opts, err := c.TxOpts(ctx, true) if err != nil { return nil, err }