# Getting Started

> Deploy a smart contract on Flare using your browser.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

Source: https://dev.flare.network/network/getting-started

You can deploy your first smart contract and run it in your browser without prior knowledge of Flare. This guide demonstrates how easy it is to develop smart contracts using the [Solidity language](https://www.soliditylang.org/), a [MetaMask wallet](https://metamask.io/) and the [Remix Development Environment](https://remix.ethereum.org/). All these tools are accessible in your browser for free, without requiring any sign-up.

## Goals[​](#goals "Direct link to Goals")

You will create and deploy a simple "Hello World" smart contract following these steps:

1.  **Write:** Draft a smart contract outlining its logic, updating a simple string state variable.
    
2.  **Compile:** Convert your human-readable smart contract code into bytecode, comprehensible to the Flare blockchain.
    
3.  **Deploy:** Send the compiled smart contract to the blockchain, where its code becomes immutable.
    
4.  **Call functions:** Execute the functions defined in your contract, triggering changes in the state of the blockchain.
    

## Steps[​](#steps "Direct link to Steps")

<details>
<summary>1. Install, configure and fund your MetaMask wallet</summary>

**1\. Install, configure and fund your MetaMask wallet**

1.  [Install the MetaMask browser extension wallet](https://metamask.io/download/)
    
2.  After installing, open MetaMask from your browser extensions.
    
    ![](/assets/images/0-open-metamask-2786922695f772da59cc366631f70aee.png)
3.  Follow the instructions to create a new wallet. During setup, you'll receive a 12-word mnemonic phrase. Safeguard this phrase in a secure location, as it's crucial for accessing your wallet in the future.
    
4.  Add the Flare Testnet Coston2 to your MetaMask wallet. Go to the [Coston2 Explorer](https://coston2-explorer.flare.network), and click on **Connect** in the top right hand corner.
    
5.  A MetaMask prompt will open asking you to approve adding the network. Click on **Approve**.
    
    ![](/assets/images/2-approve-coston2-5fa25c3211ad679de8fdc73c79bd7a90.png)
6.  Once approved, MetaMask will ask you to switch to Flare Testnet Coston2. Click on **Switch network**.
    
    ![](/assets/images/3-switch-networks-a5526628ab8b08d49bd237e10304bf13.png)
7.  Copy your MetaMask address.
    
    ![](/assets/images/4-copy-address-0ed3549ec0a8a96ccd09378a2047e8a5.png)
8.  Paste your address in the [Coston2 Faucet](https://faucet.flare.network/coston2) and click on **Request C2FLR**.
    
    ![](/assets/images/5-paste-address-613bda69191f8c3d1a8281ee66230e0c.png)
9.  After the faucet completes the transaction, which can take a few seconds, you should find testnet C2FLR in your MetaMask wallet.
    
    ![](/assets/images/6-after-faucet-confirmation-ce1991a8b741aa4505d10f34415a8089.png)

With your wallet configured and funded, you're ready to write, compile, and deploy your contract.

</details>
<details>
<summary>2. Write, compile and deploy your first smart contract</summary>

**2\. Write, compile and deploy your first smart contract**

Start with a simple HelloWorld.sol example. This contract illustrates setting and retrieving variables within a smart contract onchain.

HelloWorld.sol

```
// SPDX-License-Identifier: MITpragma solidity >=0.8.0 <0.9.0;/** * THIS IS AN EXAMPLE CONTRACT. * DO NOT USE THIS CODE IN PRODUCTION. */contract HelloWorld {    string public message;    constructor(string memory initialMessage) {        message = initialMessage;    }    function updateMessage(string memory newMessage) public {        message = newMessage;    }}
```

<details>
<summary>Didn't understand the Solidity code?</summary>

Didn't understand the Solidity code?

Let's break down the `HelloWorld` contract:

1.  **Pragma Directive:** The `pragma solidity >=0.8.0 <0.9.0;` statement specifies the version of the Solidity compiler the contract should use. In this case, the contract is compatible with any version of Solidity above (including) 0.8.0 and below 0.9.0.
    
2.  **Contract Declaration:** The `contract HelloWorld { ... }` statement defines a new Solidity contract named `HelloWorld`.
    
3.  **State Variable:** `string public message`; declares a state variable named `message`, which is of type `string` and is publicly accessible (due to the `public` visibility modifier). This variable will store a message that can be read by any external entity.
    
4.  **Constructor:** The `constructor(string memory initialMessage) { ... }` function is a special function that is executed only once when the contract is deployed. It initializes the `message` state variable with the value passed as `initialMessage` when the contract is deployed.
    
5.  **Function `updateMessage`:** This function allows anyone to update the `message` state variable. It takes a `newMessage` parameter of type `string`, updates the `message` variable with the new value, and is publicly accessible (`public` visibility modifier).

</details>

1.  [Open contract in Remix](https://remix.ethereum.org/#url=https://github.com/flare-foundation/developer-hub/blob/main/examples/developer-hub-solidity/HelloWorld.sol&version=builtin&evmVersion=cancun&optimize=true&runs=200)
    
2.  Click on `HelloWorld.sol` in the file explorer to open the contract in the Remix editor.
    
3.  Navigate to the **Solidity compiler** tab on the left to view the compiler settings.
    
    ![](/assets/images/7-open-solidity-compiler-c9422708bb14e0a3eee8ed3013128d54.png)
4.  Expand the **Advanced Configurations** section and make sure the **EVM Version** is set to `cancun`.
    
    ![](/assets/images/set-evm-version-remix-69f5d8d1405ae172504ea23012d0bf09.png)
5.  Click the **Compile HelloWorld.sol** button to compile the contract. This converts the contract from human-readable Solidity code into bytecode that the Flare blockchain can understand.
    
    ![](/assets/images/9-compile-contract-572d3c2ae7779e3f5f3abb49a8dd9799.png)
6.  After Remix compiles the contract, deploy it. On the left side of Remix, click the **Deploy & Run Transactions** tab to view the deployment settings.
    
    ![](/assets/images/10-deploy-and-run-transactions-72b6fdaeb1c1747d907352da5ddd89b4.png)
7.  In the deployment settings, select the **Injected Provider - MetaMask** environment. This tells Remix that you want to deploy your contract to the blockchain that you configured in MetaMask.
    
    ![](/assets/images/11-set-injected-provider-bfef3dea67a044c8ec18ecd24c8613f6.png)
8.  Next to the **Deploy** button, enter a message that you want to send with the smart contract when you deploy it. This contract has a constructor that sets an initial message when you deploy the contract.
    
    ![](/assets/images/14-message-when-deploying-fd2ef348b1db35eea43c07fe73e93e2d.png)
9.  Click the **Deploy** button to deploy the contract and its initial message to the blockchain. MetaMask opens and asks you to confirm payment to deploy the contract. Make sure MetaMask is set to the Flare Testnet Coston2 network before you accept the transaction. Click on **Confirm**.
    
    ![](/assets/images/15-confirm-deploy-in-metamask-eea0d99772dce839b5c86729681c5639.png)
10.  After a few seconds, the transaction completes and your contract appears under the **Deployed/Unpinned Contracts** list in Remix. Click the contract dropdown to view its variables and functions. Click the **message** button. Remix retrieves and prints the initial message that you set.
     
     ![](/assets/images/16-click-on-message-56cab7d2fb4e9e29450ad54b0f6738bb.png)

The contract has an address just like your wallet address. To see details about your deployed contract, copy the contract address from the list in Remix and search for it in the [Coston2 Explorer](https://coston2-explorer.flare.network).

</details>
<details>
<summary>3. Call functions in your contract</summary>

**3\. Call functions in your contract**

Since you deployed the contract to a blockchain, multiple nodes on the test network have confirmed your payment for the smart contract. The contract, along with its variables and functions, is now permanently stored on the blockchain. To change the `message` variable within your contract, simply run the `updateMessage` function.

1.  In your deployed contract, enter a new message next to the updateMessage function. Click the **updateMessage** button to set the new message in the contract data.
    
    ![](/assets/images/17-update-message-037ff377e25089a0724658e6f3aca52b.png)
2.  A MetaMask prompt will open and ask you to confirm payment to update the state of your contract. Click **Confirm** to approve the transaction.
    
    ![](/assets/images/18-confirm-metamask-update-message-dba7117168def7112150c04b4e756734.png)
3.  Click the **message** button again to see the updated value.
    
    ![](/assets/images/19-query-updated-message-5c5c42c71e845d90dd781fd308f40e58.png)

</details>

Now you know how to deploy and call example contracts on Flare's testnet. You can write your own contracts and test them using this same process.

## Watch the video[​](#watch-the-video "Direct link to Watch the video")

What's next?

Read FTSOv2's [Getting Started](/ftso/getting-started) guide to learn how to connect your smart contracts to Flare's enshrined oracle and retrieve onchain data feeds.
