2

everybody, I'm currently trying to learn how to automatically deploy a smart contract to the Ethereum blockchain and I heard of the JSON RPC way of doing that. There are the eth_sendTransaction and the eth_getTransactionReceipt that I think will be used at some point. Although, I didn't figure out how the transactions are signed. If someone could help me with any info I'll be very thankful.

But the main question is: Is it necessary to run an Ethereum node to automatically deploy and interact with smart contracts? This information wasn't very clear to me as a beginner. If it is necessary, is there any other way that I wouldn't need to run one node?

Thank you, guys!

1 Answer 1

2

It is not necessary to run an Ethereum node to deploy smart contracts.

One common way of deploying smart contracts is through the online IDE, Remix, that the Ethereum foundation provides:

https://remix.ethereum.org

A tutorial like this could walk you through the process.

If you specifically want to use the JSON-RPC directly, you can use a service like Infura which provides an API to access the Ethereum network through their nodes:

Infura is a hosted Ethereum node cluster that lets your users run your application without requiring them to set up their own Ethereum node or wallet.

https://infura.io/

Here is a tutorial which uses Truffle and Infura to deploy a smart contract (albeit not directly via JSON-RPC calls that you make):

Truffle Tutorials - Using Infura (or a custom provider)

In terms of creating and signing transactions, you should use a library like Web3.js:

How to properly create a raw transaction and sign it using web3 in browser

Let me know if this helps!

5
  • Just a quick question. The web3.js example is running on the user's browser right? How safe is it to leave your private key sitting there? Not at all. So how would I keep it safe on the server side? Oct 9, 2018 at 17:36
  • You can sign a transaction offline if you are worried about security. If you are using the libraries correctly, nothing should leave the confines of the computer that is running the javascript. On a service side application, you need to follow normal key management practices like using a vault. In general, when building web3.js apps, I would simply rely on metamask to do account/key management. Oct 9, 2018 at 18:28
  • Ok. So I'm trying to build a booking system and when a user makes a reservation the smart contract about that reservation goes to the blockchain. But my system would pay for this contract deployment not the user. Any suggestions on how to store my private key safely? Oct 9, 2018 at 18:40
  • I do not think I am a good person to answer that question, but I think it would be a fine post (if the answer doesnt already exist on google). Oct 9, 2018 at 18:54
  • I'll try that. Thank you for your help, Shawn! It definitely got me started! Oct 9, 2018 at 18:58

Your Answer

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

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