Title: {ETH} Как с транзакцией передавать какие-то даl Post by: Melicano on February 25, 2016, 01:31:45 PM Не могу понять, как передавать данные вместе с транзакцией. Нарпимер, чтобы с приходом транзакции было прикреплено сообщение, которое мог бы считать контракт. Можете привести пример кода и пример отправления транзакта, чтобы контракт "увидел" сообщение, переданное вместе с деньгами?
Title: Re: {ETH} Как с транзакцией передавать какие-то даl Post by: Grumlin on February 25, 2016, 09:21:34 PM Здесь пример есть, тут пирамида вместе с деньгами получает дату на 16 символов
https://ethereumpyramid.com/contract.html Title: Re: {ETH} Как с транзакцией передавать какие-то даl Post by: Xtc on February 26, 2016, 02:28:40 AM https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsendtransaction
web3.eth.sendTransaction(transactionObject [, callback]) Parameters 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. eth.sendTransaction({from: eth.accounts[0], value: web3.toWei(1, 'ether'), to: '0x....', gas: 500000, data: web3.fromAscii('Up to 16 chars !')}) Title: Re: {ETH} Как с транзакцией передавать какие-то даl Post by: Melicano on February 26, 2016, 05:07:40 AM Спасибо вам, дошло.
Добра вам. Title: Re: {ETH} Как с транзакцией передавать какие-то даl Post by: Melicano on February 26, 2016, 06:52:40 AM eth.sendTransaction({from: eth.accounts[0], value: web3.toWei(1, 'ether'), to: '0x....', gas: 500000, data: web3.fromAscii('Up to 16 chars !')}) А как контракт ловит это сообщение из data?Title: Re: {ETH} Как с транзакцией передавать какие-то даl Post by: zork on February 26, 2016, 08:09:52 AM eth.sendTransaction({from: eth.accounts[0], value: web3.toWei(1, 'ether'), to: '0x....', gas: 500000, data: web3.fromAscii('Up to 16 chars !')}) А как контракт ловит это сообщение из data?Только я не совсем понял как работать с разными типами принимаемых данных, тут https://www.reddit.com/r/ethereum/comments/4483y3/how_to_compare_msgdata_bytes_data_type_to_an/ это обсуждалось. |