Functions
Functions are the actions your contract can perform. Every time someone interacts with your contract on the blockchain, they’re calling one of its functions. Think of them as buttons that people can press to make things happen.
Two Types of Connectors
Nodes use two kinds of connectors:
- Triangle connectors control the order things happen. They chain steps together so each one runs after the last, like a to-do list you follow from top to bottom.
- Circle connectors pass data between nodes. They let one node send a value to another, like handing a number from a calculator to a form field.
Try It Yourself
The canvas below uses the real editor. Complete each task to see how functions, parameters, and data flow work together.
Give your Action a name so others can call it.
Visibility
Visibility controls who is allowed to call a function. Think of it like the doors in a restaurant:
- public: the front door. Anyone can walk in and call this function, whether they’re inside or outside the contract.
- private: the staff-only kitchen. Only code inside this contract can call it. No one else, not even contracts that inherit from yours.
- internal: the family recipe book. This contract and any contracts that inherit from it can call the function, but outsiders cannot.
- external: the drive-through window. Only callers from outside the contract can use it. The contract itself cannot call its own external functions directly.
Most functions start as public. Choose a narrower visibility when you want to restrict access.
State Mutability
State mutability tells the blockchain what a function does with stored data. This affects gas costs and how the function can be called:
- (default): the function can read and write state. This is a full transaction that costs gas.
- view: the function only reads state, never changes it. Free to call because no transaction is needed. Example: checking a balance.
- pure: the function doesn’t touch state at all. It only works with the inputs it receives. Also free to call. Example: a math helper that adds two numbers.
- payable: the function can accept native token along with the call. Required for any function that should receive cryptocurrency. Example: a deposit or purchase function.
Set mutability on the
Returns
Functions can send values back to whoever called them. Define what comes back using the Returns parameter list on the Function node.
Each return value has a type (Number, Wallet Address, True/False, etc.). To actually send the value, connect a
A function can return multiple values at once. For example, a function might return both a balance and whether the account is active.
Modifiers
Common examples:
- onlyOwner: only the contract’s owner can call this function
- whenNotPaused: the function only works when the contract isn’t paused
Type modifier names into the Modifiers text field on the
Data Location for Parameters
When a function accepts reference types (text, bytes, lists, or structs), you need to specify where the data lives in memory:
- memory: a temporary copy that exists only while the function runs. This is the most common choice.
- calldata: a read-only copy that’s cheaper to use. You cannot modify calldata values inside the function.
- storage: a direct reference to data already stored on the blockchain. Rarely used in function parameters.
Simple types like numbers, addresses, and booleans don’t need a data location because they’re always copied automatically.
What You Learned
- Functions have names that define what action the contract performs
- Parameters let callers pass data into a function
- Circle connectors carry values between nodes, while triangle connectors chain steps in order
- Visibility controls who can call a function: public, private, internal, or external
- State mutability determines whether a function reads, writes, or accepts native token
- Returns let functions send values back to the caller
- Modifiers act as guard checks that run before the function body
- Data location (memory, calldata, storage) specifies where reference-type parameters live
These are the core mechanics of building with nodes. Every contract you create will use functions with execution flow and data flow working together.
How hard was this?