Skip to main content
Version: Current

Hello, World

Welcome to Flow blockchain, Let's call a contract on Testnet blockchain. Testnet is a public blockchain, you can call contracts without any cost. The Flow blockchain is decentralized data store that allows for custom executable code known as contracts to be deployed and called. Contracts are flexible and live on the Flow blockchain forever.

Calling a contract

On Testnet, HelloWorld Contract has a public variable named greeting, we'll use a Script to get it's value. For the purposes of this quick start, we are embedding Flow Runner website to run a script against Testnet. For reference Flow Runner website


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

Copy the script above into Flow Runner and click "Execute Script" Then scroll down to see the output. Ignore the red underline of HelloWorld. Fixing this will be in future learnings.

Contract on Testnet

Here is the HelloWorld contract, Continue to other getting started examples to learn how to call changeGreeting to change the greeting value.


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

info

There are no costs associated with calling contracts.

Continue to learn to create your own contracts and deploying with Flow CLI