# (0) I Need Fuel.

I decided to join the newly introduced 'Attackathon' on the [Immunefi](https://immunefi.com/boost/fuel-network-attackathon/) platform; it's a first for them, and for me. Not only is there a big prize pool to be won, but it's also introducing a new programming language, Sway, which I'm sure will be challenging and fun to learn... Here's hoping.

> ## What's an Attackathon?
> 
> Attackathons are education-based bughunting contests where whitehat hackers compete over a reward pool by submitting impactful bugs in the project's code.
> 
> **Before the Attackathon**  
> Immunefi works with the project to host a security-focused education period, providing top tier education and support to security researchers.
> 
> **During the Attackathon**  
> Whitehats experience ideal bughunting conditions, with direct project support, responsiveness, and duplicate rewards.
> 
> **After the Attackathon**  
> Immunefi spotlights the security accomplishments, with a custom leaderboard, Attackathon findings report, bug fix reviews, and NFT awards.
> 
> Ultimately, Attackathons serve to secure projects, develop their security ecosystem, and create new opportunities for whitehats.
> 
> source: [Fuel Attackathon | Immunefi](https://immunefi.com/academy/fuel-network-attackathon/)

Before going deep into Fuel, I thought I'd have a look and feel for the Sway programming language. Using the [documentation](https://fuellabs.github.io/sway/v0.60.0/book/index.html), I'll get setup and follow the [Developer Quickstart Quide](https://docs.fuel.network/docs/intro/quickstart/) for one of the development tutorials.

---

## Smart Contract Quickstart: Fuel <s>Injection</s> Installation

*NB: I'm using VS Code as my editor, and I will continue my journey with Radicle and use that as my repo instead of Github. Also, I installed the Sway extension as recommended by Fuel.*

We firstly create a working directory and initialise a git repo.

```bash
mkdir counter-tutorial
git init
```

Then we install fuel following the [instructions](https://docs.fuel.network/guides/contract-quickstart/)

```bash
curl https://install.fuel.network | sh
```

Straightforward and didn't run into any issues. I then did the update steps just in case.

```bash
fuelup update
updating the 'latest-x86_64-unknown-linux-gnu' toolchain
[00:00:00] [########################################] 4.84 KiB/4.84 KiB (0s) - Download complete                                                                                                   Downloading: forc forc-explore forc-wallet fuel-core fuel-core-keygen 

latest updated
  updated components:
  - forc 0.60.0
  - forc-explore 0.28.1
  - forc-wallet 0.7.1
  - fuel-core 0.26.0
  - fuel-core-keygen 0.26.0
```

---

## The counter contract

So the following command will generate our Sway contract, I guess this is similar to any tutorials that provide pre-built examples to use.

```bash
forc template --template-name counter counter-contract
```

After this I can initialise my Radicle repo too.

```bash
rad node start
rad init
```

**Output:**

* [The Radicle repo](https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z33zCPgNNzPxBBuJMRMjhgGbZHzwt)
    

```bash
rad init

Initializing radicle 👾 repository in /home/pxng0lin/web3/immunefi/fuel/fuel-tutorials..

✓ Name Fuel tutorials
✓ Description Fuel tutorials for development with Sway
✓ Default branch main
✓ Visibility public
✓ Passphrase: [REDACTED*]
✓ Unsealing key...
✓ Repository fuel-tutorials created.

...
```

```bash
counter-contract
├── Forc.toml
└── src
    └── main.sw

1 directory, 2 files
```

### Building (compiling) the contract.

Following the instructions we can now build the contract

```bash
forc build
  Creating a new `Forc.lock` file. (Cause: lock file did not match manifest)
  Removing core
  Removing counter
  Removing std git+https://github.com/fuellabs/sway?tag=v0.31.1#c32b0759d25c0b515cbf535f9fb9b8e6fda38ff2
    Adding core
    Adding std git+https://github.com/fuellabs/sway?tag=v0.60.0#2f0392ee35a1e4dd80bd8034962d5b4083dfb8b6
   Created new lock file at /home/pxng0lin/web3/immunefi/fuel/fuel-tutorials/counter-contract/Forc.lock
  Finished debug [unoptimized + fuel] target(s) in 3.56s
```

Next we will setup a local wallet, this comes along side Fuel so we shouldn't have any issues here either.

```bash
forc wallet new
```

Since this is a tutorial I won't make the password complex, I'm more than likely to forget if I do.

```bash
Wallet mnemonic phrase: [REDACTED]
```

We will create a new wallet account to get our fuel address using the command `forc wallet account new`.

```bash
Please enter your wallet password to derive account 1: 
Wallet address: [REDACTED]
```

### Deploying our contract

We will now deploy to the testnet by running the command `forc deploy --testnet`. Once we've provided the password for our wallet we should receive confirmation of deployment.

**Error!**

What's this? So we are unable to deploy since we have 0 funds in our wallet. So in the tutorial we can get some funds from the [faucet](https://faucet-testnet.fuel.network/)

After fuelling up we will try that again.

```bash
 forc deploy --testnet
  Finished release [optimized + fuel] target(s) in 3.28s

Please provide the password of your encrypted wallet vault at "[REDACTED]": 

---------------------------------------------------------------------------
Account 1: [REDACTED]

Asset ID : f8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07
Amount   : 2000049
---------------------------------------------------------------------------

Please provide the index of account to use for signing: 1
Do you agree to sign this transaction with [REDACTED]? [y/N]: y


Contract counter-contract Deployed!

Network: https://testnet.fuel.network
Contract ID: 0x71a2a7efd28e8b80388105cb3bb52ca5e100b21cb034ee6e44a5ffb135f7f361
Deployed in block 0018e86c
```

**Success!**

This finished the tutorial! So I'll also wrap it up here. The next step they have are further tutorials.

I'll have a read through the [Sway documentation](https://docs.fuel.network/docs/sway/) to get a better feel of what I'm looking at in the contract, and potentially move on to [Sway Program Types](https://docs.fuel.network/docs/sway/sway-program-types/) and build a Predicate following the tutorial; until the next article, thanks for reading.
