Blockchain {from:thessponsor,value:10000000,gas:3000000}是一个固态的msg对象吗?

Blockchain {from:thessponsor,value:10000000,gas:3000000}是一个固态的msg对象吗?,blockchain,ethereum,solidity,Blockchain,Ethereum,Solidity,以太坊智能合约中有以下代码: personal.unlockAccount(thesponsor,"password"); ss.pledge("Good luck with the run!", {from: thesponsor, value: 10000000, gas: 3000000}); 但是,质押函数不是应付修饰符,它只接受一个参数作为参数: function pledge(bytes32 _message) { if (msg.value == 0 || complet

以太坊智能合约中有以下代码:

personal.unlockAccount(thesponsor,"password"); 
ss.pledge("Good luck with the run!", {from: thesponsor, value: 10000000, gas: 3000000}); 
但是,质押函数不是应付修饰符,它只接受一个参数作为参数:

function pledge(bytes32 _message) {
  if (msg.value == 0 || complete || refunded) throw;
  pledges[numPledges] = Pledge(msg.value, msg.sender, _message);
  numPledges++;
}
那么,solidity是否会自动将{from:thessponsor,value:10000000,gas:3000000}视为从我的帐户传输以太的msg对象


我只是觉得这个功能有点过时了。如果我写了一个json对象,恰好包含关键字“from”和“value”,我会不小心转移任何资金吗

我希望半年后你已经找到了解决问题的办法,但如果你还没有找到

是的,您的观察是正确的,
{from:theponsor,value:10000000,gas:3000000}
被解释为
事务对象。这是因为以太坊上任何导致状态改变(即您创建、更新或删除数据)的
交易都需要
交易对象,如上图所示,以允许您的代码在区块链上执行

在下面的代码段中,您可以看到
request
函数导致第4行和第5行的状态更改。这就要求您为交易提供
gas
。此外,
质押
使用了
msg.value
,这是您在质押中发送的以太坊金额的值,由
表示

1  // add a new pledge
2  function pledge(bytes32 _message) {
3    if (msg.value == 0 || complete || refunded) throw;
4    pledges[numPledges] = Pledge(msg.value, msg.sender, _message);
5    numPledges++;
6  }
关于第二个问题,请查看
transactionObject
的结构。以太坊中的函数(如果它们进行状态更改)将首先接收函数的参数,然后是后面的
transactionObject
。因此,只需确保不要意外地编写
transactionObject
,因为它将被解释为事务