Superhero.com - a truly decentralized social tipping platform!

published: June 14, 2020
Author: Marco Walz

In may 2020 the æternity development community announced the official launch of Superhero.com - a truly decentralized social tipping platform that can be used to support content creators and good causes instantly without any intermediary in between.

This means that no funds will be lost due to commissions and publishers do NOT need to proceed KYC in order to receive tips!

Sounds too good to be true? We can certainly say that there is absolutely no hidden downside! The source code of all components is open sourced on GitHub.

How does that work? What's going on behind the scenes?

A regular user won't notice much of the "magic" that is happening behind the scenes. But for all those interested we want to provide a deep dive on what's going on behind the scenes and explain why the æternity blockchain is perfect to build a platform like Superhero upon.

Step 1 - Superhero Wallet: Tip

The user decides to tip a URL by using the Superhero Wallet. In order to be able to perform a tip the user needs to have AE tokens to cover the tip amount as well as the (cheap) transaction fee.

When the user confirms this action the smart contract function tip is being executed and the tip is stored in the smart contract until it is claimed by the publisher that is eligible to do so.

Thanks to the ÆNS (æternity naming system) it is very easy to look up the address of the tipping contract. E.g. you can use ænalytics to see the contract address where superhero.chain points to.

sequenceDiagram Superhero Wallet->>Tipping Contract: 1) tip: https://kryptokrauts.com Superhero Wallet->>Superhero Backend: 2) trigger claim (https://kryptokrauts.com, ak_...) Superhero Backend->>Tipping Contract: 2.1) pre-claim (url, address) Tipping Contract-->>Oracle Contract: 2.1.1) query oracle (url, address) Oracle Contract-->>Multiple Oracles: 2.1.2) query trusted oracles (url, address) Multiple Oracles-->>Oracle Contract: 2.1.3) found address or no response Superhero Backend->>Tipping Contract: 2.2) claim (url, address) Tipping Contract-->>Oracle Contract: 2.2.1) check if address is allowed to receive payout for url Tipping Contract-->>Recipient address: 2.2.2) payout sum of all tips for the url

Step 2 - Superhero Wallet: Trigger claim

A publisher (or eligible recipient) triggers a claim for the tips of a certain URL using the Superhero Wallet. In this case the official Superhero backend will perform the required actions on behalf of the user. This allows publishers to claim tips without the need to buy AE tokens.

Note:

  • In order to be eligible the claimer needs to have the æternity address (ak_...) or the ÆNS name (*.chain) of the Superhero Wallet included in the html of the URL. We for instance included the ÆNS name in the head of our website:

    <meta name="aens-name" content="kryptokrauts.chain" data-react-helmet="true">
    
  • In case of Twitter or GitHub profiles the recipient can add the æternity address (ak_...) or the ÆNS name (*.chain) to the biography.
  • The following steps (in this case performed by the Superhero backend) can also be performed "manually" by any other user. It is possible to claim the tips on behalf of other users by providing the address of the eligible user. This is actually also what the Superhero backend is doing. The Superhero Wallet provides the address of the user to the Superhero backend which then tries to claim the tips on behalf of the user.

Step 2.1 - Superhero Backend: Pre-claim

The Superhero backend receives the address of the Superhero Wallet as well as the current URL and calls the pre-claim function of the tipping contract providing this information.

Step 2.1.1 - Tipping Contract: Query oracle

The tipping contract calls the query_oracle function of the oracle contract.

Step 2.1.2 - Oracle Contract: Query trusted oracles

The oracle contract which manages a list of trusted oracles performs the actual query for each of the minimum required amount of oracles.

Step 2.1.3 - Multiple Oracles: respond if address is found

Each of the trusted oracles runs a service to poll queries and if requested performs a logic to determine whether the expected address is included in the html of the provided URL. The oracles only respond if the expected address is found.

Step 2.2 - Superhero Backend: Claim

This action is only performed when the check_claim function of the tipping contract succeeds. The aepp-sdk-js which is used in the Superhero backend automatically performs a dry-run call as the check_claim function isn't stateful.

This allows the Superhero backend to check if a pre-claim was successful without having to pay any fee to do so. The returned value of the check_claim function is of type success_claim and contains the attributes success (bool), account (address) and percentage (int).

The logic to create the response value of type success_claim is performed in the oracle contract where the oracle responses are being analyzed.

The claim function of the tipping contract will only be performed if the dry-run call of the check_claim function returns a value where the attribute success is true.

Step 2.2.1 - Tipping Contract: check allowance

Before performing the actual payout the tipping contract needs to ask the oracle contract whether the given address is allowed to receive the tips within the claim function.

The logic happening behind the scenes is similar to the logic that was previously triggered by the Superhero backend when check_claim was called. This time a "real transaction" will be executed as the claim function is stateful.

It is important to mention that the logic requires that >50% of the oracles to respond with the expected address. Otherwise the payout won't be executed!

Step 2.2.2 - Tipping Contract: payout

When the allowance check in the previous step is successful and the tip amount for the URL is greater than zero the the tipping contract will perform the payout and the address provided to the claim function will receive the tips.

Superhero video explainer by Philipp Piwowarsky

Typical questions

  • Is this really free to use?

    • YES, it is!
  • What is the difference to the tipping system of Brave?

    • Currently the tipping system in Brave is not truly decentralized. The biggest problem here is that publishers need to create an account on Uphold and proceed KYC in order to receive the tips. These tips are then credited to their Uphold account on a monthly basis. The transactions are not traceable on the blockchain and thus we cannot be 100% sure that everything is going right. In Superhero instead the tips are sent to a smart contract on the æternity blockchain and immediately accessible/claimable by the publishers. This provides full transparency about what URLs have been tipped and what address received the tip if it has been claimed already.
    • Note:

      • We are still big fans of the Brave browser. If you aren't using it yet you should read this article. Brave and Superhero are complementary which means you can use both tipping systems to send and receive tips! ;-)
  • Can I tip any public URL?

    • YES, you can tip any public URL.
  • How can I participate?

100% Open Source

As already mentioned Superhero is 100% open source and available on GitHub. Check out the following repositories:

Æternity - the blockchain for Superheroes!

The Superhero platform is built on top of æternity and it is the first decentralized æpp that demonstrates how some of æternitys powerful features can be utilized.

Features used by the Superhero platform

The following features of æternity are used within the Superhero platform.

ÆNS

The æternity naming system can be used by publishers which can include the *.chain name on their website or on their social media profiles (e.g. Twitter or GitHub). A name can have unlimited pointers (with different keys) and following pointer keys are defined in the protocol:

  • account_pubkey
  • contract_pubkey
  • oracle_pubkey
  • channel

The naming system allows e.g. to send AE tokens directly to a name within a SpendTx. This only works if the account_pubkey is set and the protocol is able to determine the address to send the tokens to.

Oracles

In æternity oracles are first class citizens which means that they are built into the core protocol. There is no need for developers to develop contracts that define how oracle queries and responses should be handled. Sophia (æternitys smart contract language) provides built-in methods to register and/or communicate with oracles.

Smart Contracts

As already mentioned æternity introduced a new functional OCaml like smart contract language called Sophia. The syntax of Sophia most resembles that of Reason. Unlike most other smart contract blockchains æternity isn't using the EVM (Ethereum Virtual Machine) anymore and consideres the AEVM (modified EVM) as deprecated in the future.

Instead FATE was invented which is a type safe high-level virtual machine which contracts safe up to 90% storage compared to similar EVM contracts.

Additional features (not explicitely used by the Superhero platform)

Æternity provides many other great features. We encourage everyone to check out the website to learn more about æternity. In this article we want to highlight the answers of æternity to existing scalability issues.

Bitcoin-NG (scaling on-chain)

Besides the features mentioned above æternity aims to solve existing scaling problems and was the first blockchain that implemented Bitcoin-NG consensus protocol. The use of Bitcoin-NG makes it possible for æternity to perform up to ~116 transactions per second (on-chain).

State channels (scaling off-chain)

Another solution that was introduced to improve scalability are so called state channels. The idea behind state channels is that two parties can open a channel where they deposit funds and after the channel is opened those parties can perform transactions in a secure and trustless manner without the need of a blockchain (off-chain).

The blockchain will after a channel is opened only be used in following cases:

  • to solve a dispute if one party tries to cheat
  • to close the channel
  • to deposit additional funds

The state channel functionality is probably the most powerful feature of æternity and of course this is also part of the core protocol. In Ethereum for example there exist many different projects that aim to provide state channel solutions by making use of smart contracts. In August 2019 several projects joined forces and announced the initiative StateChannels.org to unify around a single standard.

Æeternity ships its own reference implementation of state channels with the core protocol. Of course there is still a lot work to do (e.g. to make state channel usable on mobile phones) but the foundation was laid and state channels can already be used!

Give us some of your superpower!

If you like the article and already have the Superhero Wallet we would be happy if you leave us some of your superpower.

Thank you!