Skip to content

Latest commit

 

History

History

lesson-07-scope

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Lesson 7: Variable Scope

In this lesson we'll fetch some basic price data for $CRV to serve as the oracle price. In the process we'll cover topics such as returns, function scope decorators, and local variables.

Note that now we are working against contracts deployed to mainnet, so tests will work better if you run them using a mainnet fork. We also recommend installing Brownie Token Tester. Full instructions are available in unit 6 of the accompanying Brownie Tutorial.

INTERNAL FUNCTIONS

A function decorated with an @internal decorator can only be called from within the contract. Internal functions can be called via the self object, and must be called after they are defined.

VARIABLE SCOPE

Vyper has three types of variables, accessible within different scopes.

  • Storage: data written to the blockchain, globally accessible via the self object
  • Memory: helper variables used within the scope of a single function and discarded
  • Calldata: arguments passed to a function by the contract caller, then discarded