1

I am trying create an application using NodeJS, web3, ganache and write a smart contract with solidity on Ethereum as a part of my final year project. Reading the documentations, I still have a few questions which I could not understand -

1) When we deploy the smart contract via web3 (server code), where does the smart contract actually get deployed? Because the JSON contract build file is still on the server, right?

2) Does every user need to have their own deployed version of smart contract?

3) If we are deploying smart contract via server for each user, wouldn't it create a bottleneck on the server? Because all the requests are going to the server first, then how is the application decentralized?

4) Do users need to install ganache, metamask, etc. if they want to connect to the application running on a private Ethereum blockchain network?

Please clarify my doubts and correct my understanding if I am wrong.

1

1) When we deploy the smart Contract via web3 (server code), where does the smart Contract actually get deployed? Because the JSON contract build file is still on the server, right?

A Provider abstracts a connection to the Ethereum blockchain to interact with it. You can either connect to an existing provider such as:

  • "mainnet"
  • "rinkeby"
  • "ropsten"
  • "kovan"
  • or in your case your own private Ethereum

To deploy a contract to the Ethereum you need the Contract bytecode and Application Binary Interface (ABI), usually generated from the Solidity compiler. Solidity is the programming language used on Ethereum to write smart contracts.

2) Does every user need to have their own deployed version of smart Contract?

No, most of the time, users need to interact with a single contract. Each Contract has its own state. Every deployed Contract has a unique address. If you're implementing two simple contracts, A and B, to save a list of names, if you call contract A to add a name, it will be added only on A.

3) If we are deploying smart Contract via server for each user, wouldn't it create a bottleneck on the server? Because all the requests are going to the server first, then how is the application decentralized?

Not really, your server is just a gateway to interact with the blockchain and especially smart contracts. But too many users can indeed overload your server but not the blockchain at this scale.

4) Do users need to install ganache, metamask, etc. if they want to connect to the application running on a private Ethereum blockchain network?

No, Ganache and Truffle Suite, in general, are a collection of development tools and environments. Metamask, most of the time, yes, it's a web3 provider that allows you to sign transactions, to interact with smart Contracts using your Wallet.

| improve this answer | |
  • Thanks for the clarification! However, for the third question, if all requests from users are going via the server then why or how is it considered as a decentralized application? – surhud004 Feb 26 at 23:40
  • Also, if the server is down or restarted, wouldn't the smart contract lose its state and its variable values be reset? – surhud004 Feb 26 at 23:44
  • "server" is only one way among others to communicate with the blockchain, state is saved on the blockchain, not on the server. Server is used to send requests to the blockchain, but while your server is down the blockchain is still running as long as miners continue mining. – Adam Boudjemaa Feb 26 at 23:48
  • One more thing, if your server is down, you can still interact with the smart contract. It is considered as a decentralized application since the smart contracts are automatically executed, and a third party does not control it, and it can't be shutted down – Adam Boudjemaa Feb 26 at 23:57
  • 1
    Thanks for the information. Now I understood how I should design my application. I thought everytime app is started we need to deploy a copy of smart contract. Thanks a lot. – surhud004 Feb 28 at 5:28

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.