fizzy.axa Smart Contract explained

Alexandre CLEMENT
7 min readJun 13, 2018

--

This article is dedicated to explaining the details of the Ethereum transactions that are published on the Ethereum Blockchain by fizzy.

This article will present everything from the ground up, so you may continue reading even if it’s the first time you hear about Ethereum! 😊 (However, if you want a thorough explanation of Ethereum, there are way better sources to explain this project in detail, like www.ethereum.org itself)

If you want to skip straight to the part where you can double-check the actual landing time of your flight, please see section 2. Flight landing.

EDIT: This section now also details the event generated by the Smart Contract after the Flight Landing

What is fizzy?

fizzy is a fully automatic parametric flight delay insurance, with a blockchain twist.

You can go on https://fizzy.axa, enter your flight details, get a quotation (what you will pay for the insurance and what you will receive if there is a delay of 2 hours or more), subscribe and follow your policies.

If you subscribed a policy and your flight lands with 2 hours of delay or more, you’ll receive your compensation directly on your bank account. No claims, no hassle!

What is Ethereum?

Ethereum is a public Blockchain. Which means everyone can read the content of the transactions that are validated by the nodes of the network (even though you cannot tell whose identity is behind the public addresses).

However, Ethereum comes with a pretty interesting icing on the cake: Smart Contracts!

The principle is easy: anyone can host a piece of code on the Ethereum blockchain. It is then possible to call this piece of code with a transaction and make it run on the Ethereum Blockchain.

Both the pieces of code and the transactions are readable by anyone (with a tad bit or retro-engineering, hence this article)

fizzy’s Smart Contract

… can be found at this address on the ETH blockchain: 0xe083515d1541f2a9fd0ca03f189f5d321c73b872

In order to have a look at the status of the contract (i.e. all transactions From / To this contract), you can use the block explorer etherscan: https://etherscan.io/address/0xe083515d1541f2a9fd0ca03f189f5d321c73b872

Click on any TxHash to see the details on the transaction!

If you are at ease with Solidity, you may also review the Smart Contract’s code: https://etherscan.io/address/0xe083515d1541f2a9fd0ca03f189f5d321c73b872#code

Before diving in the transactions, let’s see what the Smart Contract does. It has three main functionalities:

  • addNewInsurance: in order to add an insurance policy
  • updateFlightStatus: in order to update an insurance policy with the actual landing time of a flight
  • manualInsuranceResolution: this function may for instance be used if you choose to cancel your policy before the flight. fizzy as to comply with that legal obligation and we wanted you to be able to keep track of it.

So, we basically use the Smart Contract twice for each policy: at subscription and at flight landing.

What happens when I subscribe to an insurance against flight delay?

1. Subscription

Once you have entered your flight details, chosen a level of coverage and subscribed your insurance policy (against payment) on https://fizzy.axa, you’ll receive an e-mail confirmation including the TxHash (basically, an address for a transaction in the Ethereum Blockchain) of your policy subscription:

The TxHash you’ll receive in your Subscription e-mail

What happened there? We took your flight details, and entered them in the Blockchain thanks to the addNewInsurance functionality of our Smart Contract! Don’t worry, no personal information other than the flight details and a randomly generated ID are stored in the Blockchain.

https://etherscan.io/tx/0x0bacc0b00b3e7996c20b2f4e211bbf3b51dc3da6e477c70ddb4dde5fca89eeab

If you follow the link in the e-mail, you’ll land on a page describing the specifics of a transaction.

You can see in the “Input Data” box that we indeed used the addNewInsurance function with the following parameters:

[0]: flightID, the unique ID of your flight

[1] : Limit time of arrival, if your plane lands after this threshold, we will send a compensation, whatever the cause!

[2] : the premium you paid to subscribe to your insurance policy

[3] : the compensation you’ll get if the flight lands with a delay of 2 hours or more

[4] : the productID, a randomly generated ID used by fizzy to identify your policy. No one else but you and fizzy can associate it to you.

That’s interesting, but still not straightforward to read! That’s because those values are encoded, quite hard to read for a human! Let’s take it step by step:

a. [0] : flightID

First, go in the details of the transaction, like here. Copy all of the flightID line and go to an Hexadecimal to String converter. In this example we’ll use codebeautify

When inputing the flightID value, we have the following tansformation:

41462e32322e3135333034303332303030303000000000000000000000000000AF.22.1530403200000

Those characters are your flight code associated with the date of departure (in local time!). Those values allow fizzy to identify your specific flight.

  • AF22: your flight, from Paris to New-York (AF : Air France aviation code)
  • 1530403200000: the date of departure (local time) of this flight, in TimeStamp

You still have one step to go in order to get a human readable date of departure (local time). In this example, we’ll use epochconverter. Just input your timestamp and click on “Timestamp to human date”:

After clicking on the yellow button, you’ll access a human-readable date

1530403200000Sunday 1st of July 2018

So, now we know that this transaction corresponds to the booking of a policy for the flight AF22, departing on the 1st of July 2018 (local time).

b. [1] : Limit time of arrival

In this variable, fizzy entered the time (UTC) at which your flight is supposed to land + 2 hours. This defines the time after which we will compensate for the delay of this flight!

You should convert the line from Hexadecimal to Decimal, in order to get the timestamp. In this example, we’ll use rapidtables

(You can skip all the zeroes in the beginning of the line!)

16456dbc200 — 1530465600000

Then, we just have to convert this timestamp to a human readable time (see epochconverter above)

1530465600000 Sunday 1st of July 2018 17:20:00 (UTC)

So now, we know that this transaction has subscribed an insurance policy against delay for the flight AF 22 departing (from Paris) on the 1st of July 2018 and that a compensation will be paid if this flight lands after 17:20:00 (UTC) on the 1st of July!

[2] & [3] are simply hexadecimals values corresponding to your insurance premium and indemnity. Use a converter to check the amount in € !

2. Flight landing

After your flight landing, you’ll receive an e-mail notifying you of your eligibility to a compensation or not (i.e. has your flight been late of 2 hours+ or not?)

Whatever the result, you’ll also get the TxHash corresponding to your flight landing. This time, we used the UpdateFlightStatus functionality, as clarified in the “Input Data” box

The Input Data box in the transaction details

[0]: The flight ID, you can use the same method as above to decipher it (Hexadecimal to string, then you get the flight code and the date of departure (local) as a timestamp!)

[1]: This is where we input the actual landing time of your flight! The format is once again hexadecimal, so just convert it to decimal (you can skip the zeroes at the beginning) and then to a human readable date (see websites links above — this exemple is not the same flight as above)

163dab8e360 (hexadecimal) — 1528382940000 (decimal, timestamp) — Thursday the 7th of June 14:49:00 (UTC)

Based on this value, an event is generated by the Smart Contract and sent back to fizzy, in order to trigger a € compensation, if the flight landed after the limit time of arrival.

2.1. Event generated by the Smart Contract

By looking at the Smart Contract code, we can see that there is an InsuranceUpdate event defined. This event is included in the UpdateFlightStatus functionality and reports the final status of the contract.

The piece of code including the insurance status, after flight landing

If you go to the “Event Log” of an UpdateFlightStatus transaction, you’ll see the details of this event for this specific flight:

The Event Logs contains the data sent by the Smart Contract to fizzy to communicate the status of the insurance contract

As defined above, there are 2 main statuses:

  • 1 : flight landed before the limit, no compensation
  • 2 : flight landed after the limit, compensation

As defined in the InsuranceUpdate event, the last value is the status of the contract.

The Event Logs allows you to convert the values from Hexadecimal to a Number or Text in one click! That way, you can check quickly whether the last one is 1 (no compensation) or 2 (compensation)

The day we’ll shift to ether-payment, this event will automatically be linked to your indemnification in ETH.

I hope this helped you understand the fizzy project a bit better! Please do not hesitate to suggest additional content or explanation

--

--