New blockchains are springing up like mushrooms. So in the crypto field, you have to be careful because it’s easy to get scammed. But in this post, I’ll share some thoughts on a blockchain that, in my opinion, has some prospects and potential future.

The chinese version is available at https://mp.weixin.qq.com/s/PfwLnv9Kcl8N8xTvMChInw

In my opinion, blockchain projects can be divided into three categories:

  • I. Scam projects and sh*tcoins

The blockchain industry is not very well regulated (maybe completely unregulated?), not counting centralized crypto exchanges. It has its advantages and disadvantages. The most obvious advantage is no one can restrict your access to your assets as long as you store them in a non-custodial wallet.

And one of the most obvious disadvantages is anyone can create a blockchain or a project based on an existing blockchain, collect money from investors and disappear with the collected money. Such cases were much more frequent a couple of years ago when a lot of projects were doing ICOs without fulfilling promises they made to investors.

  • II. Fork/rebranding of an existing blockchain with a couple of tweaks

There are a lot of projects that just forked already popular blockchains like Ethereum or Bitcoin, added a couple of new features or/and fixed some of the issues.

In the top 20 of the most popular cryptocurrencies, there are several examples:

  • Binance smart chain is a fork of Ethereum from the Binance exchange. It has a different consensus algorithm, lower fees and faster block time.
  • Polygon is another fork of Ethereum. It positions itself as a layer-2 solution for Ethereum.
  • Dogecoin is a fork of Bitcoin. Initially, it was done as a joke. But now it seems it’s taken seriously, and even Elon Musk is making money on it by pumping its price

These projects are secondary, and I’m not sure what is going to happen with them in the long term. But there are multiple examples of Ethereum’s layer 2 solutions that ceased to exist

  • III. Innovative new projects

This category includes projects that were developed from scratch, bringing some innovative ideas to life. It seems to me TON (the open network) belongs to this category.

TON

TON is a blockchain initially developed by the Telegram messenger team. Now the development is done by the TON foundation (due to some issues with the United States Securities and Exchange Commission).

TON positions itself as the third generation blockchain (Bitcoin is the first generation, and Ethereum is the second generation). Of course, TON draws inspiration from the Ethereum blockchain and to me, it seems an improved version of Ethereum. Ton performs better in terms of scalability (tps), block time and performance (transaction complexity). From the TON’s blog, it mentions the following advantages compared to Ethereum:

  • Smart contracts have to pay rent for their storage

In Ethereum, the cost of a smart contract’s storage is paid once. But miners / validators will have to keep paying infrastructure costs to retain this data for years to come because the chain is eternal.

In Ton, a smart contract will have to pay fees for its storage. Otherwise, it will be deleted

  • Calls between smart contracts are asynchronous and not atomic

In Ethereum, all calls between smart contracts have to happen in the same transaction. In Ton, potentially, you can have thousands of calls because calls are asynchronous, and they don’t have to be executed in a single transaction

  • smart contracts are not immutable

In Ethereum, smart contracts are immutable so solidity developers came up with workarounds like proxy contracts to mitigate this issue

On top of the TON blockchain a couple of interesting projects were launched:

But the most obvious selling point of the TON blockchain is its integration with the Telegram messenger. Since the project was initially built by the Telegram team, it seems they still have some kind of connection to it. The telegram team recently launched an auction platform on the ton blockchain (fragment)

TON SDK for Elixir

Since the TON blockchain is relatively new, there are no tools to work with it using the most programming languages. It seems the main SDKs to work with TON are tonweb written in javascript and ton written in typescript.

I had to create a new library for Elixir to be able to work the TON blockchain. The main issue I discovered is that you have implement pretty low level algorithms (serialization/deserialization) to be able to submit a transaction. Ideally, it would be better to have something like Bitcoin’s signrawtransaction, which signs and serializes transactions; its output can be used to submit a transaction.

The library provides the following features:

  • Generate a keypair from a mnemonic
  • Parse an address
  • Serialize a transaction

It doesn’t have an http client, which in my opinion, should be trivial to implement

Let’s go over some examples

Create a keypair from a mnemonic

A mnemonic is a secret combination of 24 words that are used to derive private and public keys. The derived public key is used in address creation; the private key is needed to sign transactions.

Ton.mnemonic_to_keypair("rail sound peasant garment bounce trigger true abuse arctic gravity ribbon ocean absurd okay blue remove neck cash reflect sleep hen portion gossip arrow")

%Ton.KeyPair{
  secret_key: <<149, 222, 63, 223, 23, 72, 240, 224, 233, 177, 155, 16, 101,
    229, 182, 172, 23, 131, 54, 43, 195, 139, 217, 194, 100, 19, 252, 105, 68,
    30, 96, 95, 73, 245, 11, 185, 76, 95, 180, 99, 83, 74, 157, 13, 240, 216,
    227, 155, 203, 147, 16, 149, 137, 218, 246, 81, 151, 233, 21, 28, 55, 119,
    64, 47>>,
  public_key: <<73, 245, 11, 185, 76, 95, 180, 99, 83, 74, 157, 13, 240, 216,
    227, 155, 203, 147, 16, 149, 137, 218, 246, 81, 151, 233, 21, 28, 55, 119,
    64, 47>>
}

Parse an address

Ton.parse_address("UQCAIBANQeQX6UHmRgxHGR44oUL7VOQE9v4dxmla23KpjKIj")

{:ok, %Ton.Address{test_only: false, bounceable: false, workchain: 0, hash: <<128, 32, 16, 13, 65, 228, 23, 233, 65, 230, 70, 12, 71, 25, 30, 56, 161, 66, 251, 84, 228, 4, 246, 254, 29, 198, 105, 90, 219, 114, 169, 140>>}}

if bounceable is true, the message will be “bounced” back carrying the remainder of the original value (minus all message transfer and gas fees).

bounceable=false means that the receiver is a wallet and bounceable=true is a custom smart contract

Serialize a transaction

keypair = Ton.mnemonic_to_keypair("rail sound peasant garment bounce trigger true abuse arctic gravity ribbon ocean absurd okay blue remove neck cash reflect sleep hen portion gossip arrow")
wallet = Ton.create_wallet(keypair.public_key)
{:ok, to_address} = Ton.parse_address("EQAHJQ6gs2NYAXsxsfsucpqhpneZaGP0qCdu9lCEzysMGzst")
params = [seqno: 5, bounce: true, secret_key: keypair.secret_key, value: 1, to_address: to_address, timeout: 60]

<<181, 238, 156, 114, 65, 1, 2, 1, 0, 167, 0, 1, 225, 136, 0, 5, 230, 220, 65, 102, 30, 28, 201, _tail::binary>> = Ton.create_transfer_boc(wallet, params)

Conclustion

The project is available on GitHub

The TON project and DoraHacks platform have announced a virtual hackathon that will kick off on Jan. 30, 2023, and end on March 31. I think it can be a fun way to get some TON experience.

Comments