The Prospector’s Lantern — Anatomy of a Simple Asset.

Kerosense lamp is a promotion happening now by the massively multiplayer online economics game, Prospectors.io. Users pass the lamp from one to the next. Everyone who successfully passes the burning lamp gets a free ticket to start playing Prospectors.io three days early, on June 28th instead of July 1st. You have to keep the lantern burning to get your ticket.

The Prospector’s Lantern is also a cool, simple example of how Simple Assets saves developers hundreds of hours of work.

The eos account kerosenelamp created three digital assets:

Firstly, the non-fungible Lamp. In its mutable-data, the kerosene lamp has the field ison (is on) to track whether or not the lamp is burning.

Then two fungible tokens: FUEL, and SPARK.

As a simple asset, the ownership of the lamp, fuel and sparks is expressed outside the control of the kerosenelamp contract. When you own these things, you own them outright.

How do you fuel and light the lamp?

First you need to get FUEL and a SPARK, which you can do through the kerosene lamp interface.

This adds fungible FUEL and SPARK tokens to your account. Theoretically, you could sell the fuel in a third party marketplace like Simple Market — and the lamp as well, should you become the owner.

When you use the interface to “refuel” the lamp you transfer fungible tokens from your personal account to the kerosenelamp account. To simulate a limited capacity for fuel, we use the common EOSIO practice of listening for notifications created by the require_recipient function and reject transactions with too much fuel.

Sending a SPARK token to the lantern causes the lantern to light, assuming it has fuel. Behind the scenes, the kerosenelamp contract receives a fungible SPARK token, burns it, and change the ison variable in its mutable data.

While the lamp is lit, it periodically burns the fungible fuel tokens in its possession, simulating the consumption of fuel. Differed transactions are used to mark time.

In the interface, the size of lamps flame is proportional the amount of remaining fuel. This is currently sorted out off chain on the front end to save RAM, though it could also be handled by an additional field in the lamp’s mutable data.

How does happening the lamp give users free tickets?

The Prospectors tickets are also simple asset fungible tokens, created by the account prospectorsa. For the purpose of this promotion, 200 such fungible tokens were transferred to the kerosenelamp account.

Simple Assets have event notifications for all ownership actions, so it is easy for the kerosenelamp account to identify transfers. When one happens, the account checks if the lamp was lit during the transfer, and checks that the user hasn’t already received a ticket. If these conditions are satisfied, the user who passed the lamp get a ticket.

There is much more to simple assets than what is demonstrated by the Kerosene Lamp. There is built-in lending/borrowing, containerization, and more. Check out our github (https://github.com/cryptolions/simpleassets) or join our Telegram channel (https://t.me/simpleassets) to learn more.

???

CryptoLions is an EOS Block Producer based in Ukraine. We strive to make EOS more valuable by building projects that improve the ecosystem, by setting the standard for transparency and accountability, and by popularizing EOS all over the world.

website: http://cryptolions.io/
github: https://github.com/CryptoLions
telegram: https://t.me/CryptoLions_io
steemit: https://steemit.com/@cryptolions
twitter: https://twitter.com/EOS_CryptoLions
medium: https://medium.com/@cryptolions/
youtube: https://www.youtube.com/channel/UCB7F-KO0mmZ1yVBCq0_1gtA