Web3.py: raise validation error if trying to send ether to a contract function with payable=False

Created on 13 Jun 2018  Â·  13Comments  Â·  Source: ethereum/web3.py

What was wrong?

When methods are marked with payable=False in the ABI, a transaction sending ether to them will (or should) fail. Web3 isn't doing anything to intercept these calls, leaving callers to debug the failing transaction.

How can it be fixed?

When running a call, transact, estimateGas, or buildTransaction, inspect the transaction's value field. If it is present, and non-0, check the function ABI. If payable is present and False, raise a validation error explaining that the user must not send ether to functions that are not payable.

Alternative approach: when searching for matching functions in the ABI, filter out options that are not payable if the transaction has non-0 value. Not sure that this really buys anything besides fitting into a framework we already have.

Good First Issue

Most helpful comment

Hi, I'm taking a look at this as a way to get started with issues.

All 13 comments

Hi, I'm taking a look at this as a way to get started with issues.

Update: I'm sorry about the delay. I'm setting up the development and booting it up in Docker Compose and jumping in.

...and all tests pass. Nice to see.

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__This issue now has a funding of 165.0 DAI (165.0 USD @ $1.0/DAI) attached to it.__

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work has been started__.

These users each claimed they can complete the work by 11 months from now.
Please review their action plans below:

1) jong86 has applied to start work _(Funders only: approve worker | reject worker)_.

Hi I'm going to check this out.
Plan is:

  1. find related code
  2. write tests for this additional feature
  3. ensure these tests pass

thanks

Learn more on the Gitcoin Issue Details page.

2) ankit-maverick has been approved to start work.

  1. Raise ValidationError in transact, estimate_gas & build_transaction functions
  2. Get the approach & code reviewed by @carver
  3. Write appropriate tests for this change.
  4. Get the PR merged after all everything is green from CircleCI

Learn more on the Gitcoin Issue Details page.

These users each claimed they can complete the work by 12 months from now.

This timeline seems unnecessarily long. If it is taking longer than 6-8 weeks, I would expect to pass it on to the next person who wants to take a shot. I think that's plenty.

@carver I will take a shot at this. Should take less than a week.

@carver that timeline issue is on me... should have set a lower timeline when creating the issue. Accepting @ankit-maverick, thanks for providing a timeline.

@ankit-maverick Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • [x] warning (3 days)
  • [ ] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


@ankit-maverick due to inactivity, we have escalated this issue to Gitcoin's moderation team. Let us know if you believe this has been done in error!

  • [x] warning (3 days)
  • [x] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@ankit-maverick Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • [x] warning (3 days)
  • [ ] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Done and merged!

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work for 165.0 DAI (165.0 USD @ $1.0/DAI) has been submitted by__:

  1. @ankit-maverick

@vs77bb please take a look at the submitted work:

  • PR by @ankit-maverick

Was this page helpful?
0 / 5 - 0 ratings