0

I have a project with Ethereum Blockchain the users send the data to the server and the server writes the data in the blockchain network My question is how do I represent the server in the smart contract? I guess I got it wrong when I said server If I said that the server is a user in the network My question, do you have an idea how each user can send data to the contact

2 Answers 2

0

All sorts of interactions on the Ethereum Blockchain happen via "Transactions". Now these transactions are carried out by -

  1. Users via externally owned accounts
  2. Smart contracts. You, the user should have a private key(from this a 20-byte address is generated which represents your account on the network).

Now to send data to a smart contract via a transaction, the user has to create a transaction object and sign that object before submitting it to the transaction pool.

In your case, from what I understand, you need to provide the server with the private key file, so that it can create the transaction object with the required data, sign and submit to the network. The data should be the relevant encoded arguments/bytecode of the smart contract function that you wish to invoke. Truffle, parity have good tools which you can use to accomplish this. Or if you're comfortable with much core-components, you can use geth. There're detailed articles on these tools available on the internet.

3
  • I don’t know if I understand what I mean, I simply have a number of servers that store data that have this data. I want to store it in a blockchain network. This data is automatically obtained from devices or sensors, regardless of where it is obtained. The idea is that this data is not entered through the web application, I am sending this data through Python.
    – esraa
    Jun 29, 2020 at 13:09
  • according to what I understand, every server must have the address of this address that I get from the ganache. I am in this state, in the smart contract I have specified the sender's address, in which case the condition is that more than one address means more than one sender, and these addresses are specified in web3.py also. I don't know if you did it right or not
    – esraa
    Jun 29, 2020 at 13:09
  • So you've specified addresses in the smart contract, from which a particular function call can be made right? In that case, no worries, just give the private key file access to the servers, it'll send the data with the function call transaction.
    – Tirtha
    Jun 30, 2020 at 1:41
0

I have a project with Ethereum Blockchain the users send the data to the server and the server writes the data in the blockchain network My question is how do I represent the server in the smart contract?

Every interaction with Ethereum contracts is executed via addresses. Your server is just another address. You could define roles and restrict certain contract funktions to specific addresses. For an example you can look to Open Zeppelin and "ownable".

I guess I got it wrong when I said server If I said that the server is a user in the network My question, do you have an idea how each user can send data to the contact.

If it is a public network, users can interact with your contract. Your users need a node they can query and the contract address. A public interface to the blockchain could be "Infura".

1
  • When I say each server is an address the same web3.eth.account in web.js or web.py This means more than one server and more than one address or account When there is more than one account, does it affect security ??
    – esraa
    Jun 24, 2020 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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