Ethereum web3.eth.sendTransaction传递参数和强制transactionObject
阿罗哈 Web3版本为0.20,根据文档: web3.eth.sendTransaction web3.eth.sendTransaction(transactionObject[,回调]) 将事务发送到网络。 参数Ethereum web3.eth.sendTransaction传递参数和强制transactionObject,ethereum,solidity,web3js,Ethereum,Solidity,Web3js,阿罗哈 Web3版本为0.20,根据文档: web3.eth.sendTransaction web3.eth.sendTransaction(transactionObject[,回调]) 将事务发送到网络。 参数 Object - The transaction object to send: from: String - The address for the sending account. Uses the web3.eth.defaultAccount property, if n
Object - The transaction object to send:
from: String - The address for the sending account. Uses the web3.eth.defaultAccount property, if not specified.
to: String - (optional) The destination address of the message, left undefined for a contract-creation transaction.
value: Number|String|BigNumber - (optional) The value transferred for the transaction in Wei, also the endowment if it's a contract-creation transaction.
gas: Number|String|BigNumber - (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).
gasPrice: Number|String|BigNumber - (optional, default: To-Be-Determined) The price of gas for this transaction in wei, defaults to the mean network gas price.
data: String - (optional) Either a byte string containing the associated data of the message, or in the case of a contract-creation transaction, the initialisation code.
nonce: Number - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
Number|String - (optional) If you pass this parameter it will not use the default block set with web3.eth.defaultBlock.
Function - (optional) If you pass a callback the HTTP request is made asynchronous. See this note for details.
我有一个函数placeBet(),它接受多个参数:
function placeBet(uint8 _outcome, uint desiredMatchIndex, uint _amount) public payable{
// find a way to store a bid in order to be easily searchable, in order to easily send money to winners;
// require(!roundEnd, "Interactions with contract are locked, be careful next time!");
// require(state == State.Active, "Betting is over, game have already started!");
require(msg.value > 0, "It isn't possible to place a bet without a money ");
if(!isDuplicate(msg.sender)) addressIndices.push(msg.sender);
testina(msg.sender, _outcome, desiredMatchIndex);
existingBets[msg.sender].push(Bet({
bettor: msg.sender,
// name: name,
amount: _amount,
bet: desiredMatchIndex,
outcome: _outcome
}));
//emit event, finally;
}
,所以我的问题是,我应该如何将所需的额外参数(结果、desiredMatchIndex、金额)[可能最后一个是reduntant]包括在一起
使用web3.js的transactionObject
谢谢:)哦,很抱歉,文档中有一个示例,只是没有充分引用
/ Explicitly sending a transaction to this method
myContractInstance.myMethod.sendTransaction(param1 [, param2, ...] [, transactionObject] [, callback])
也许它和调用函数一样?(transactionObject,参数…)