Solidity之msg是什么
solidity
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.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。