Back to glossary

Private and Public State Variables (Vyper Code Example)

Table of Contents

Private state variables cannot be accessed from outside the contract.

Public state variables can be read by anyone, including users and other contracts.

# pragma version ^0.4.0

# publis state variable
owner: public(address)
# private state variable
foo: uint256
bar: public(bool)

@deploy
def __init__():
    self.owner = msg.sender
    self.foo = 123
    self.bar = True

Related Terms

No items found.