美文网首页
Solidity之msg是什么

Solidity之msg是什么

作者: charlieyan | 来源:发表于2018-04-23 20:51 被阅读0次
    image.png

    msg.value is automatically set to the amount of ether sent with that payable function.

    msg.value的值被设定为和message一起发送过来的以太币(以wei为单位)
    mag.value不是gas fee

    Simply put the msg object is the pack of data you are sending in transactions. *When simply sending ether from one address to another msg.data will be empty. *When calling upon a contract without having to send ether with the call msg.value will be 0 and msg.data will contain the calldata
    当只是从一个地址向另一个地址转账以太币时,msg.data为空

    当调用一个合约而不用发送以太币时msg.value是0 同时msg.data包含了调用的数据(具体我也不知道是什么数据,日后再详细补充)


    image.png

    Essentially, a message is like a transaction, except it is produced by a contract and not an external actor. A message is produced when a contract currently executing code executes the CALL opcode, which produces and executes a message. Like a transaction, a message leads to the recipient account running its code. Thus, contracts can have relationships with other contracts in exactly the same way that external actors can.

    本质上来说 message有点像交易 除了它是由合约产生的之外。(总觉得哪里不太对,欢迎讨论)

    Note that the gas allowance assigned by a transaction or contract applies to the total gas consumed by that transaction and all sub-executions. For example, if an external actor A sends a transaction to B with 1000 gas, and B consumes 600 gas before sending a message to C, and the internal execution of C consumes 300 gas before returning, then B can spend another 100 gas before running out of gas.

    相关文章

      网友评论

          本文标题:Solidity之msg是什么

          本文链接:https://www.haomeiwen.com/subject/fdxrlftx.html