February 15, 2020 by The Btc News
That is the second article in our collection on integrating cost channels on Telegram Open Community. Within the first half, we launched the community, detailed our expertise of the competition, and defined how synchronous and asynchronous sensible contracts work. As the subsequent addition to the collection, this text particulars how we constructed a synchronous cost
That is the second article in our collection on integrating cost channels on Telegram Open Community. Within the first half, we launched the community, detailed our expertise of the competition, and defined how synchronous and asynchronous sensible contracts work. As the subsequent addition to the collection, this text particulars how we constructed a synchronous cost channel on the community throughout TON’s contest again in September. Right here, we will likely be speaking solely about Fift (TON’s general-purpose programming language) and FunC (TON’s programming language for writing sensible contracts).
The TON white paper supplies extra in-depth details about cost channels, however we’ll briefly clarify them once more.
Code of the sensible contract as a single cell (normally written in FunC, then compiled into Fift ASM code and included in the principle .fif file utilizing path-to-compiled-asm.fif).
Preliminary storage of the sensible contract (see beneath).
New sensible contract handle (the hash from the preliminary state of the sensible contract that additionally consists of the sensible contract code cell and the preliminary storage cell).
Arguments of the primary name of the recv_external perform (the quantity of arguments and sort will depend on the contract).
An exterior message cell for initialization, which will likely be serialized into bytes and packed to the .boc file, which consists of all the info from factors 1–four and a few extra ones which are nonetheless missing documentation.
seqno 32 bits
contract_status four bits
first_user_pubkey. The primary get together’s public key 256 bits
second_user_pubkey. The second get together’s public key 256 bits
time_to_send. Time to ship after the very first state being submitted 32 bits (legitimate till 2038)
depositSum. The deposited sum of two members as much as 121 bits
state_num 64 bits. The present quantity of states that occurred
The consumer generates an extra physique payload that features a message (for instance, 1 bit) and its signature in a separate .fif file.
Physique payload is compiled to a .boc file.
Physique payload is loaded from this .boc file right into a .fif file as a body-cell “transferring” reference (the .fif is liable for transferring GRAMs from the pockets).
The recv_external perform known as with arguments (the deposit quantity and the vacation spot handle of the channel) when the compiled .fif file is distributed to the community.
The send_raw_message perform is executed. Deposited GRAMs and extra physique payload is distributed to a P2P channel sensible contract vacation spot handle.
The recv_internal perform of the P2P channel sensible contract known as. GRAMs are obtained by channel contracts.
Good contract handle (to exclude the opportunity of coming into the right state from the earlier P2P channel with the identical members).
The ultimate steadiness of the primary participant.
The ultimate steadiness of the second participant.
The deposited quantity from the storage needs to be equal to the sum of the whole balances of the members.
The brand new entered state quantity should be better than or equal to the earlier one.
Proceed Studying on Coin Telegraph
Disclaimer: Fusion Media
want to remind you that the info contained on this web site isn’t essentially real-time nor correct. All CFDs (shares, indexes, futures) and Foreign exchange costs are usually not offered by exchanges however slightly by market makers, and so costs is probably not correct and should differ from the precise market value, which means costs are indicative and never applicable for buying and selling functions. Due to this fact Fusion Media doesn`t bear any accountability for any buying and selling losses you would possibly incur on account of utilizing this knowledge.
Fusion Media or anybody concerned with Fusion Media won’t settle for any legal responsibility for loss or injury on account of reliance on the knowledge together with knowledge, quotes, charts and purchase/promote alerts contained inside this web site. Please be totally knowledgeable concerning the dangers and prices related to buying and selling the monetary markets, it is likely one of the riskiest funding varieties potential.