0

I have created coins on test network.Now the confusion is,

I have distributed coins to 100 members,who can use those coins to buy digital products(domains) on my platform.Now the confusion is if all domains are listed for sale for $10(100 coins),and multiple domains got sold,how can I identify which user made payment to me.Because all users can see my wallet address.Is there any way to detect that payment came in for which purchased product?

  • Not only would we have to see your code, but you seem to be forgetting that in a transaction you can see where the coins go, where they came from, and usually you can attach some arbitrary data, which could be your product info. – David Hoelzer Jan 01 '18 at 13:17

2 Answers2

1

Make your wallet into a smart contract.

Then checkout the fallback function payable. That function gets called anytime someone sends ether to your contract.

function () payable {
    address guyWhoPaiedMe = msg.sender;
  }

To figure out who sent you the ether use msg.sender.

Richard Garfield
  • 455
  • 1
  • 5
  • 13
1

You can pass the identifier of a particular product as the input data of the transaction. In this case it will be easy to identify the product against which the payment was made.

web3.eth.sendTransaction web3.eth.sendTransaction(transactionObject [, callback])

Sends a transaction to the network.

Parameters 1. 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. 2. Function - (optional) If you pass a callback the HTTP request is made asynchronous. See this note for details.

Returns

String - The 32 Bytes transaction hash as HEX string.

Mouazzam
  • 469
  • 1
  • 4
  • 15
  • Thanks,I agree with inputData as product info.But user selected to pay using MyEthereumWallet then how it will be possible.In this situation it will be user's responsbility to add product info and user may give erong product info. – Harsh Aatpadkar Jan 13 '18 at 15:29