В качестве web3.personal.signAndSendTransaction
метода. Есть ли такой метод для функций контракта? Например:
MyContract.storeName.signAndSendTransaction("name",
{from:web3.eth.accounts[0]},"passphrase");
Нет, к сожалению.
Что вам нужно сделать, так это закодировать подпись контракта и параметры в формате Application Binary Interface (ABI), а затем отправить эти данные в data
параметре web3.personal.signAndSendTransaction
функции.
См. параметр данных в JavaScript API — web3.eth.sendTransaction :
Параметры
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.
Чтобы выяснить, какие данные отправлять, ознакомьтесь с пошаговым примером под заголовком « Использование вашего контракта с помощью curl и JSON-RPC » в разделе « Как вызвать метод контракта с помощью eth_call JSON-RPC API » . этот сайт и проверьте Ethereum Contract ABI .