File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -272,8 +272,11 @@ func (c *BoundContract) RawCreationTransact(opts *TransactOpts, calldata []byte)
272
272
// Transfer initiates a plain transaction to move funds to the contract, calling
273
273
// its default method if one is available.
274
274
func (c * BoundContract ) Transfer (opts * TransactOpts ) (* types.Transaction , error ) {
275
- // todo(rjl493456442) check the payable fallback or receive is defined
276
- // or not, reject invalid transaction at the first place
275
+ // Check if payable fallback or receive is defined
276
+ if ! c .abi .HasReceive () && (! c .abi .HasFallback () || ! c .abi .Fallback .Payable ) {
277
+ return nil , fmt .Errorf ("contract does not have a payable fallback or receive function" )
278
+ }
279
+
277
280
return c .transact (opts , & c .address , nil )
278
281
}
279
282
You can’t perform that action at this time.
0 commit comments