0

How can I see a smart contract address & know which addresses sent ether to my smart contract? And Can a smart contract have multiple receiving addresses.... like for example if I am selling e-books can every e-book have its own address so that the sales of each book is transparent or do I have to have multiple smart contracts “talking” to each other for this to happen?

0

How can I see a smart contract address and know which addresses sent ether to my smart contract?

A tool like Etherscan can help you look at an address, and transactions from that address via your web browser. If you want to do something programmatically, you will need to use a Web3 library like Web3.js or Web3.py.

Can a smart contract have multiple receiving addresses?

No. A specific contract will have one address which can be used to interact with it.

...Can every e-book have its own address so that the sales of each book is transparent or do I have to have multiple smart contracts “talking” to each other for this to happen?

Neither approach you mention above is a good one in this situation. It seems like you want to build a pretty simple "store" smart contract, where users can purchase different items using ETH, and prove that they have made that purchase using a record on the blockchain.

You will need a contract which can:

  • Define an owner for the "store" (see Zeppelin Ownable)
  • Allow owner to register an item (Name, Price, etc...) (probably in an Array)
  • Allow a user to send ETH for a particular item
  • Check the amount of ETH sent is correct for the item's price
  • Store which users successfully completed a purchase
  • Allow owner to withdraw funds

This can all be done with a single contract. Then you will need to build a user interface, to interact with that contract.

Probably best to start with something that has been built already like this (although I have never used or reviewed this smart contract, so you will need to review this yourself):

https://github.com/brakmic/BlockchainStore

  • Thanks @Shawn Tabrizi I am satisfied with the first two answers but in the third one not really. I want anyone to be able to see how many books have been bought and by how many addresses... more like the way we see the block explorer... – YulePale Aug 14 '18 at 8:17
  • All data about purchases of the books will naturally be public due to the nature of Ethereum. Furthermore, you can add "getter" functions which allow you to specifically query that information. – Shawn Tabrizi Aug 14 '18 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.