Bitcoin Forum
May 06, 2024, 06:50:07 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: {ETH} Как с транзакцией передавать какие-то даl  (Read 4944 times)
Melicano (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
February 25, 2016, 01:31:45 PM
 #1

Не могу понять, как передавать данные вместе с транзакцией. Нарпимер, чтобы с приходом транзакции было прикреплено сообщение, которое мог бы считать контракт. Можете привести пример кода и пример отправления транзакта, чтобы контракт "увидел" сообщение, переданное вместе с деньгами?
In order to get the maximum amount of activity points possible, you just need to post once per day on average. Skipping days is OK as long as you maintain the average.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715021407
Hero Member
*
Offline Offline

Posts: 1715021407

View Profile Personal Message (Offline)

Ignore
1715021407
Reply with quote  #2

1715021407
Report to moderator
1715021407
Hero Member
*
Offline Offline

Posts: 1715021407

View Profile Personal Message (Offline)

Ignore
1715021407
Reply with quote  #2

1715021407
Report to moderator
Grumlin
Legendary
*
Offline Offline

Activity: 2886
Merit: 1137



View Profile WWW
February 25, 2016, 09:21:34 PM
 #2

Здесь пример есть, тут пирамида вместе с деньгами получает дату на 16 символов

https://ethereumpyramid.com/contract.html


           ▄
         ▄███
         ▀████▄
       ▄  ▀████▄
      ███▄ ▀████▄
    ▄████   ▀████▄
   ▄████      ████▄
  ▄████        ████▄
 █████          █████
▀████▄          ▄████▀
  ▀████▄▄▄▄   ▄████▀
    ▀████▀  ▄████▀
LISK
       ▄▄▄▄▄▄▄
   ▄▄▀▀       ▀▀▄▄
  █               █ ▄
 █   █▀▄ ▀█▀ ▀█▀   █ ▀▄
 █   █▀▄  █   █    █  ▀▄
  █  ▀▀   ▀   ▀   █    █
▄▀ ▄▄           ▄▀    ▄▀
 ▀▀  ▀▀▄▄▄▄▄▄▄▀▀      ▀▄
        ▀▄▄      ▄▄▀▀▄▄▀
           ▀▀▀▀▀▀

                      ▄▄▄
  ▄█▄              ▄███████▄
  ▀████▄▄         ██████▀██████▀
    ▀▀▀████▄▄     ███████████▀
    ▀██▄███████▄▄███████████
     ▄▄▄▀██████████████████
      ▀████████████████████
▀█▄▄     ▀████████████████
  ▀████████████████▀█████
    ▀████████████▀▄▄███▀
       ▀▀██████████▀▀
           ▀▀▀▀▀

    ▄█▄            ▄█▄
   █████          █████
  ███████ ▄▄▄▄▄▄ ███████
 ▄██████████████████████▄
 ████████████████████████
██████████████████████████
██████▀▀          ▀▀██████
█████▀   ▄      ▄   ▀█████
 ████   ███    ███   ████
  ████   ▀      ▀   ████
   ▀████▄▄▄▄▄▄▄▄▄▄████▀
     ▀▀████████████▀▀

               ▄▄   ▄▄
              ▄▀ ▀▀█  █
             ▄▀     ▀▀
         ▄▄▄▄█▄
     ▄█▀▀▀▀▀▀▀▀▀▀█▄
 ▄▀▄▀              ▀▄▀▄
█  █   ▄█▄    ▄█▄   █  █
 ▀█    ▀█▀    ▀█▀    █▀
  █                  █
   █   ▀▄      ▄▀   █
    ▀▄   ▀▀▀▀▀▀   ▄▀
      ▀▀▄▄▄▄▄▄▄▄▀▀






   ▄▄████████████████▄▄
 ▄█████▀▀▀██████▀▀▀█████▄
▄████▀  ▀▀▀    ▀▀▀  ▀████▄
████▀                ▀████
███▀                  ▀███
███       ▄    ▄       ███
██▀      ███  ███      ▀██
██       ▀█▀  ▀█▀       ██
██▄     ▄        ▄     ▄██
▀██▄     ▀▀▄▄▄▄▀▀     ███▀
 ▀███▄▄▄▄▄▄████▄▄▄▄▄▄███▀
   ▀▀████████████████▀▀

   ▄▄███████████████▄▄
 ▄█████████████████████▄
▄██████████████▀▀███████▄
████████████▀▀    ███████
█████████▀▀   ▄   ███████
██████▀▀     █    ███████
████▀       █     ███████
█████▄▄   ▄█      ███████
████████ ██▄      ███████
▀████████ ▀▄███▄▄███████▀
 ▀█████████████████████▀
   ▀▀███████████████▀▀

   ▄▄████████████████████▄▄
 ▄██████████████████████████▄
▄████████████████████████████▄
██████████ ▀▀█████████████████
██████████     ▀▀█████████████
██████████         ▀▀█████████
██████████         ▄▄█████████
██████████     ▄▄█████████████
██████████ ▄▄█████████████████
▀████████████████████████████▀
 ▀██████████████████████████▀
   ▀▀████████████████████▀▀


  ▄▄███████████████▄▄
 █████████████████████
███████████████████████
███████████▀    ███████
██████████  ▄██████████
██████████  ███████████
████████      ▄████████
██████████  ███████████
██████████  ███████████
██████████  ███████████
 █████████████████████
  ▀▀███████████████▀▀
Xtc
Legendary
*
Offline Offline

Activity: 1972
Merit: 1028


;u


View Profile WWW
February 26, 2016, 02:28:40 AM
 #3

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 !')})
Melicano (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
February 26, 2016, 05:07:40 AM
 #4

Спасибо вам, дошло.
Добра вам.
Melicano (OP)
Newbie
*
Offline Offline

Activity: 14
Merit: 0


View Profile
February 26, 2016, 06:52:40 AM
 #5

eth.sendTransaction({from: eth.accounts[0], value: web3.toWei(1, 'ether'), to: '0x....', gas: 500000, data: web3.fromAscii('Up to 16 chars !')})
А как контракт ловит это сообщение из data?
zork
Legendary
*
Offline Offline

Activity: 1487
Merit: 1008



View Profile
February 26, 2016, 08:09:52 AM
 #6

eth.sendTransaction({from: eth.accounts[0], value: web3.toWei(1, 'ether'), to: '0x....', gas: 500000, data: web3.fromAscii('Up to 16 chars !')})
А как контракт ловит это сообщение из data?
в контракте function() { if(msg.data == x) {doSomething();} }
Только я не совсем понял как работать с разными типами принимаемых данных, тут https://www.reddit.com/r/ethereum/comments/4483y3/how_to_compare_msgdata_bytes_data_type_to_an/ это обсуждалось.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!