Skip to main content

Hello World Pt. 1 - Basics

Welcome to the Flow blockchain! In this quickstart guide, you'll interact with your first smart contract on our Testnet. For those unfamiliar, the Testnet is a public instance of the Flow blockchain designed for experimentation. Here, you can deploy and invoke smart contracts without incurring any real-world costs.

Smart contracts on Flow are permanent code that live on the blockchain, allowing you to encode business logic, define digital assets, and much more.

Calling a contract​

The HelloWorld contract exposes a public variable named greeting that is accessible to everything outside the contract. We can retrieve its value using a simple script written in the Cadence programming language.


_10
import HelloWorld from 0x9dca641e9a4b691b
_10
_10
access(all) fun main(): String {
_10
return HelloWorld.greeting
_10
}

  • Click To vertically orient Flow Runner editor.
  • Copy the script above into Flow Runner input area and click "Run".
  • See the output returned by the script.

Contract on Testnet​

Below is the source code for the HelloWorld contract. As you continue through the next few tutorials, you'll discover how to invoke the changeGreeting function to modify the greeting value. Do take note, however, that only the contract's owner or permitted accounts can modify the greeting.


_12
access(all) contract HelloWorld {
_12
_12
access(all) var greeting: String
_12
_12
access(account) fun changeGreeting(newGreeting: String) {
_12
self.greeting = newGreeting
_12
}
_12
_12
init() {
_12
self.greeting = "Hello, World!"
_12
}
_12
}

info

There are no read costs associated with calling contracts.

Continue to create your own contracts and get them deployed live with Flow CLI!