web3.personal.signAndSendTransaction als Vertragsmethode?

Als web3.personal.signAndSendTransactionMethode: Gibt es eine solche Methode für Vertragsfunktionen? zum Beispiel:

MyContract.storeName.signAndSendTransaction("name",
    {from:web3.eth.accounts[0]},"passphrase");

Antworten (1)

Leider nein.

Was Sie tun müssen, ist, die Vertragssignatur und die Parameter im Format Application Binary Interface (ABI) zu codieren und diese Daten dann im dataParameter der web3.personal.signAndSendTransactionFunktion zu senden.

Siehe den Datenparameter in der JavaScript-API - web3.eth.sendTransaction :

Parameter

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.

Um herauszufinden, welche Daten gesendet werden müssen, sehen Sie sich das Schritt-für-Schritt-Beispiel unter der Überschrift Use Your Contract Using curl And JSON-RPC in How to call a contract method using the eth_call JSON-RPC API an, suchen Sie nach „ABI“ on diese Seite, und sehen Sie sich Ethereum Contract ABI an .