How does the Starton blockchain Relayer work ?

Hello everyone and welcome back for a new article on the Starton Relayer : our special blockchain transaction management solution to say…

How does the Starton blockchain Relayer work ?

Hello everyone and welcome back for a new article on the Starton Relayer: our special blockchain transaction management solution to say goodbye to provider and nonce issues!

In this article, we’ll see :

  • I) What is the Relayer?
  • II) When can it be useful?
  • III) Why you’ll need it
  • IV) How it works in more depth
  • V) Conclusion

I) What is the Relayer ?

At Starton, we previously were developing a tokenisation platform based on blockchain before working on Starton Connect.

During the development of this product we realised how having a transaction management system in production is not as easy to handle and maintain that we initially thought.

And you could be tempted to code your own blockchain transaction management system with web3.js or ethers.js, as we did, but you’ll soon realise that it is a very tricky thing to deal with.

This is why we adapted our Starton Relayer to enable anyone to have a robust system in production, without all the burden of development and the maintenance it implies!

The Relayer is a tool for any developer to easily interact with blockchain from a simple API request.
For short, you can see it as an API layer above blockchain protocols to make them easier to interact with.

Possible interactions can be :

  • A standard transaction (sending funds to someone)
  • Calling a smart contract’s function
  • Deploying a new smart contract on any of our supported blockchains networks

II) When can it be useful?

Relayer is especially useful in situations where you want to automatically deploy smart contracts or create blockchain transactions / call a smart contract’s functions from your backend.

For example :

  • You have a Shopify and want to automatically mint an NFT when you sell a product
  • You want to transfer crypto every time you are paid in fiat
  • You want to build a bot using Discord, Twilio, Twitter etc … and you want to interact with blockchain on specific events
  • You have a video game and want to mint NFTs to your players when bosses are defeated

III) Why you’ll need it

Let’s say you would like to develop your own system. Here are a few critical constraints you’d need to handle :

  • With a high transaction throughput, the same nonce can be given for multiple concurrent transactions if not managed properly, thus creating lost transactions because only one can be accepted by the network for a given nonce.
  • You’ll have to maintain compatibility with protocols. For example, the structure of the Ethereum transaction objects changed with the EIP-1559
  • You will have to maintain connections to (and pay) several providers as some of them could crash or stop responding at anytime
  • This implies having a robust quorum mechanic as well to take decisions
  • You’ll have to create your own solution, or pay services, to keep an accurate gas price estimate for your transactions
  • Even then, your transactions can be stuck as the average gas price can change quickly on-chain
  • The providers can even loose your transactions (for example if they crash)
  • The mempool on most EVM based blockchains is limited to 64 transactions for a single address, thus you’ll have to wait before sending some of your transactions. Otherwise, one of the oldest would be replaced and none of your transactions would pass anymore as one nonce would be missing.
  • All these things implies that you have to develop a robust transaction republication system to unstuck all your transactions
  • You’ll need an external service anyway to know when your transactions are included in the blockchain (like our Notify service)
  • Even when your transactions are included in the blockchain, uncle forks might happen which means you’d need to rollback previously passed transactions to pending transactions and you might have to republish them as well on the network. Otherwise, there would be a gap in nonce and none of your transactions would pass anymore.
  • You will need a secure way to store and use the wallets that will sign the transactions (we connect to the Key Management System of our customers)
  • You’ll need to keep in database the ABI and Bytecode of your smart contracts. This is needed because you’ll need it to encode your transaction data every time you interact with it

These are only some of the issues you could face in production, but we can guarantee you that they are not fun nor easy to debug …

IV) How does the Relayer work ?

Relayer’s interaction graph

The Starton Relayer is an API that can create and handle transactions on the behalf of a user. You can find all the API endpoints here.

You can see below the complete flow of a user’s smart contract transaction from the user API call to the transaction publication on blockchain.

The specific details of the Relayer’s complex mechanisms like the republication of transactions or the gas price estimation will be detailed in other more in-depth articles.

If you end up having specific questions about the Relayer or anything else related you can still ask them anyway in our Discord and we’ll be glad to help you!

V) Conclusion

As a summary, we can say that the Starton Relayer is the product of our own sweat and tears coming from having to deal with blockchain transactions in a production environment.

We are now proud and ready to share it with other people so they can focus on their business and work faster on building amazing web3 products.
All this for only a fraction of what would cost the development of such a solution.

We hope that you liked this article and that it opens your mind about all of its possibilities!

See you on the next one 👋 !