2

I have some vyper code as such:

# SPDX-License-Identifier: MIT
# @version ^0.3.3

supply: uint256
decimals: uint256

@internal
def updateSupply(_supply: uint256):
    self.supply = _supply

@external
def __init__():
    self.decimals = 18
    self.updateSupply(1000000000000000000)

But on compile, I get an error:

vyper.exceptions.FunctionDeclarationException: Function does not exist or has not been declared yet (reminder: functions cannot call functions later in code than themselves)
  contract "MyContract.vy", function "__init__", line 34:4 
       33     self.decimals = 18
  ---> 34     self.updateSupply(1000000000000000000)
  ------------^
       35

Why can't I call this function inside my constructor?

1 Answer 1

1

I was compiling with an older version of vyper. This feature was introduced in May of 2022

https://github.com/vyperlang/vyper/pull/2496

1
  • 1
    for ref: introduced in v0.3.4
    – gosuto
    Commented Dec 3, 2022 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.