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
. We can retrieve its value using a simple script written in the Cadence programming language.
_10import HelloWorld from 0x9dca641e9a4b691b_10_10pub 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.
_12pub contract HelloWorld {_12_12 pub 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}
There are no read
costs associated with calling contracts.
Continue to create your own contracts and get them deployed live with Flow CLI!