# Filecoin ❤️ EVM Hello World This is the story of me trying to deploy a Hello World in Filecoin. I have some (limited) experience in writting Solidity and developing Ethereum dapps, so when I learned that Filecoin now supported EVM smart contracts and that we could use Metamask for account management, I was beyond excited! https://twitter.com/protocollabs/status/1542541284061188096 ![](https://i.imgur.com/9oFmxNY.png =400x) https://twitter.com/raulvk/status/1584122228597477377 ![](https://i.imgur.com/qRQTmFU.png =400x) So, our goal for today is to deploy this `HelloWorld.sol` smart contract on the Wallaby Filecoin testnet: ```solidity=0 // Specifies the version of Solidity, using semantic versioning. // Learn more: https://solidity.readthedocs.io/en/v0.5.10/layout-of-source-files.html#pragma pragma solidity ^0.8.7; // Defines a contract named `HelloWorld`. // A contract is a collection of functions and data (its state). Once deployed, a contract resides at a specific address on the Ethereum blockchain. Learn more: https://solidity.readthedocs.io/en/v0.5.10/structure-of-a-contract.html contract HelloWorld { // Declares a state variable `message` of type `string`. // State variables are variables whose values are permanently stored in contract storage. The keyword `public` makes variables accessible from outside a contract and creates a function that other contracts or clients can call to access the value. string public message; // Similar to many class-based object-oriented languages, a constructor is a special function that is only executed upon contract creation. // Constructors are used to initialize the contract's data. Learn more:https://solidity.readthedocs.io/en/v0.5.10/contracts.html#constructors constructor(string memory initMessage) { // Accepts a string argument `initMessage` and sets the value into the contract's `message` storage variable). message = initMessage; } // A public function that accepts a string argument and updates the `message` storage variable. function update(string memory newMessage) public { message = newMessage; } } ``` ## Deploying it on Ethereum first Let's start by deploying it on a local Ethereum testnet to see what to expect. For that we'll use Remix. 1. We open Remix and create a new files called `HelloWorld.sol` ![](https://i.imgur.com/dCOMo2P.png =400x) 2. We then compile it, ![](https://i.imgur.com/safl5eJ.png =400x) 3. And then deploy it. > Note that in this example we're using the Remix VM, which is simply an EVM sandbox. ![](https://i.imgur.com/APAfbj2.png =300x) ### How this contract works If you're familiar with Solidty, the workings of this contract will be no secret to you: - We pass a string to the constructor, which is then stored on the `string public message` variable. We can then call the `update` function, which takes a string as a parameter and sets it as the value of `message`. After deployment we can then go to Deployed Contracts and click "message". The return value is "this is the first message" which is the string we passed to the constructor on the previous step. ![](https://i.imgur.com/WRMDufm.png =400x) Let's now call the update method, and see what changes: ![](https://i.imgur.com/YrWYIob.png =400x) When we check the value of `message` we see that it is now "this is the NEW message", which is the string we passed to the `update()` function in the previous step. ![](https://i.imgur.com/Kz3rvUs.png =400x) 🎉 OK! This was a Hello World in Ethereum. Time to do it in Filecoin 💪 ## Doing the same in Filecoin Wallaby The easiest way to interact with the [Wallaby network](https://github.com/filecoin-project/testnet-wallaby) is to use Metamask, since Wallaby exposes a JSON-RPC API, just like Ethereum! ### Setting up Metamask We start by adding a new network to Metamask ![](https://i.imgur.com/18IcR49.png =400x) And set the follwing settings: - Network name: Filecoin Wallaby - RPC URL: https://wallaby.node.glif.io/rpc/v0 - ChainID: 31415 (Wallaby's ) - Currency symbol: tFIL (Test FIL) Next, we create a new account to use with Filecoin ![](https://i.imgur.com/0JVhVoz.png =400x) We select the Filecoin wallaby network and this is what we should be looking at: ![](https://i.imgur.com/0ohwvVq.png =300x) ### Finding our F4 address and getting some tFIL Ethereum addresses are different from Filecoin addresses. > Ethereum addrs are translated behind the scenes to f4 (delegated) Filecoin addrs. from https://twitter.com/raulvk/status/1584122228597477377 To view our f4 address we can go to https://explorer.glif.io/ethereum/ and paste our Eth address: ![](https://i.imgur.com/BC7Ut5U.png =500x) We can now take our f4 address and get some tFIL from the faucet, which can be found at https://wallaby.network/#faucet ![](https://i.imgur.com/wt7pAEn.jpg =500x) After clicking send, we can check our Metamask and verify that we received some tFIL. ![](https://i.imgur.com/1HNeNpH.png =300x) Yay, we're in business! 🎉 ### Connecting Remix to Wallaby Goig back to Remix, at this point we already have a compiled contract. Now we just need to point Remix to the Wallaby network instead of the Remix VM. We do this by setting the environment to Inject Provider (Metamask). Since Metamask is already configured with the Wallaby network, that will be the network it will inject. ![](https://i.imgur.com/uxdNRA4.png =300x) We then deploy it! ![](https://i.imgur.com/EtairGJ.jpg) And then we wait: ![](https://i.imgur.com/7fMzAH3.png) Aaaaand success!! ![](https://i.imgur.com/kR18zmb.png) We now check the value of `message` and verify that it is "first wallaby message", which once again is the parameter we passed to the constructor. ![](https://i.imgur.com/vttVd7v.png =300x) And finally, let's try to change the value of it, using the `update()` method: ![](https://i.imgur.com/ZEGvfxw.jpg) We wait a few seconds for it to update and we verify that the transaction was successful: ![](https://i.imgur.com/sMWztf9.png) Finally we check the value of message... ![](https://i.imgur.com/k9gB5Qp.png =400x) And success! 🎉🥳 ## Summary - We deployed a Hello World contract to Remix's EVM - We used Metamask to create a Wallaby test network account - We funded our Wallaby account - We connected Remix to Wallaby, using Metamask as a provider - We deployed a Hello World to Wallaby - We interacted with our Hello World contract.