Session Token
← Back to blog

Over the last few months, core developers have been working on a smart contract which will be used to execute network operations using the new Session Token. 

The first public version of this smart contract has been released, and can now be viewed on GitHub. This is the first major milestone on the core side for the transition to Session Token. 🎉

Note that this has not yet been deployed to any chain, and now that it is public we’ll be seeking third party audits and encouraging as many people as possible to take a look at the code to ensure its security.

Splitting the codebase

The migration to Session Token will split the core of our codebase into two distinct parts:

  1. The C++ codebase: Under Oxen, this used to do everything. We will continue using this for things like tracking service node uptime, calculating rewards, and some other service node duties
  2. Smart contract system: Consisting of the Session Token contract itself, and a rewards contract which manages nodes joining/leaving the network and paying out rewards.

Role of the smart contract system

These two halves of the codebase will still be connected in some ways. The C++ codebase will observe and track events handled by the smart contract(s):

  • Node operators joining the network will call a function on the smart contract accepting their deposited stake
    • This broadcasts the details of the node to the network
  • Stakers leaving the network will notify the smart contract, triggering the 15 day unlock period
  • Stakers claiming rewards they have earnt

The first two items aren't super complicated — the smart contract simply takes the submitted information and checks some minor things (such as whether the correct stake was deposited); and broadcasts a node’s communication details to the network.

On the other hand, reward claiming functionality does use some more interesting technology to make sure the operators are only given rewards they have earnt. 

We’re utilising BLS signatures, allowing us to take multiple signatures and shrink them down into an aggregated signature which can be validated by our smart contract. This way we can make sure a majority (for example, 95%) of the network agrees on the amount before it can be claimed.

The main contract, ServiceNodeRewards.sol, is not a huge file — just 440 lines. But those lines do a huge amount of work, and they will be at the centre of our network going forward. 

The code in the smart contract was written with the valued assistance of one of the project’s expert advisors, and has undergone internal reviews. While audits are being arranged, the work on the C++ codebase will continue, with the next step being getting the workchain to record the events happening on the smart contract side of things. 

Onwards and upwards. Let’s send it.