evm/transactionoptions.go
2021-11-08 22:20:31 +04:00

40 lines
741 B
Go

package evm
import (
"context"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/shopspring/decimal"
)
type TransactOpts struct {
*bind.TransactOpts
}
func NewTransactOpts(ctx context.Context, client Client) (*TransactOpts, error) {
auth, err := client.NewTransactor()
if err != nil {
return nil, err
}
auth.Context = ctx
return &TransactOpts{
auth,
}, nil
}
func (o *TransactOpts) SetValue(value decimal.Decimal) *TransactOpts {
o.Value = value.Shift(18).BigInt()
return o
}
func (o *TransactOpts) SetGasLimit(limit uint64) *TransactOpts {
o.GasLimit = limit
return o
}
func (o *TransactOpts) SetGasPrice(gasprice decimal.Decimal) *TransactOpts {
o.GasPrice = gasprice.Shift(9).BigInt()
return o
}