blockchain - ton-solidity中的TL-B方案是什么以及如何使用?

标签 blockchain solidity tlb everscale

这个问题是关于 Everscale 区 block 链智能合约的 ton-solidity 语言。

有时,我会看到与 TL-B 方案相关的代码。例如,像这样:

function getInvokeMessage(address sender, address recipient, uint128 amount, bool bounce, TvmCell payload) public pure
        returns(TvmCell message) {
        TvmCell body = tvm.encodeBody(MsigDebot.invokeTransaction, sender, recipient, amount, bounce, payload);
        TvmBuilder message_;
        message_.store(false, true, true, false, address(0), address(this));
        message_.storeTons(0);
        message_.storeUnsigned(0, 1);
        message_.storeTons(0);
        message_.storeTons(0);
        message_.store(uint64(0));
        message_.store(uint32(0));
        message_.storeUnsigned(0, 1); //init: nothing$0
        message_.storeUnsigned(1, 1); //body: right$1
        message_.store(body);
        message = message_.toCell();
    }

我需要一步一步的解释,这段代码是做什么的?或者给我解释它的引用文档。

最佳答案

消息构造相应于 TL-B scheme .

一般来说,消息的类型称为“Message X”

该类型有 3 个部分。

第一部分是“CommonMsgInfo”

           /* int_msg_info$0
           ihr_disabled:Bool
           bounce:Bool
           bounced:Bool
           src:MsgAddressInt
           dest:MsgAddressInt */
        message_.store(false, true, true, false, address(0), address(this));
        message_.storeTons(0);//value:CurrencyCollection
        message_.storeUnsigned(0, 1);//value:CurrencyCollection (for other currencies)
        // In the next 4 fields we store zeroes, because blockchain software will replace them
        // with the correct values after this function finishes execution.         
        message_.storeTons(0);//ihr_fee:Grams
        message_.storeTons(0);//fwd_fee:Grams
        message_.store(uint64(0));//created_lt:uint64
        message_.store(uint32(0));//created_at:uint32

第二部分的类型为“init”

        message_.storeUnsigned(0, 1); //no initial state

第三部分的类型为“body”

        message_.storeUnsigned(1, 1); //1 because, we don't store body in current cell
        message_.store(body);

关于blockchain - ton-solidity中的TL-B方案是什么以及如何使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70218889/

相关文章:

blockchain - 函数中返回参数的数据位置必须是 "memory",但没有给出

hyperledger-fabric - Hyperledger Fabric 和 Hyperledger Sawtooth 中的证书颁发机构

node.js - 如何通过指定地址以太坊获取待处理交易?

javascript - 在solidity文件中查找结构

performance - 建议Prolog处理器利用大页面

x86 - 英特尔处理器的 TLB ASID 标签中有多少位?以及如何处理 'ASID overflow' ?

linux - TLB 中的内核内存(虚拟地址条目)?

node.js - 我们可以在 NodeJS 中使用 Solidity 吗?

bitcoin - 区 block 链是去中心化数据库吗?

solidity - 声明错误: Undeclared identifier Solidity