2

I don't understand how a client works. I try to explain my doubts. Since a client in the classic client-server paradigm is a lightweight application, I don't understand how this application can use the blockchain technologies. A smart contract client is a final user that could use his smartphone to access to contract API. To do this, of course, is impossible to download the blockchain on the smartphone. So, I don't understand how this client can use the smart contract without downloading a BC.

Moreover, web3js (just for citing a library) is only for nodeJS and the initialization downloads the blockchain or there are some mechanisms to avoid the download and run it on a browser like, sorry for the stupid parallelism, Angular or JQuery does? In order to imagine some application on mobile device.

2 Answers 2

1

Some of what you said is actually right, but you still don't get everything right.

The Contract API you talked about is callable via RPC ( an API structure, something like rest ). A library called JSON RPC lets you do that invocation using JS. Web3JS does the same work as JSON RPC but with better abstraction and easy to use methods.

Now, Using Web3JS to call a contract method doesn't need you to download the blockchain at all, the contract is your abstraction.

When a function in a contract is called, the contract runs the code of that function and creates a transaction which will be stored in the blockchain. Thus the only layer, in this case, that interacts with the blockchain behind the contract, is the contract itself.

So no web3 client would need to download the blockchain to use certain contract and its methods. You would understand this better if you follow a simple tutorial and make a working contract.

0

I will try to create analogy with existing Client-Server architecture.

Existing System:

Client: Any frontend written in JS(Web), android, ios(Mobile).

New System:

Client: Any frontend written in JS(Web), android, ios(Mobile).

Additional Things:

  1. Web3JS library: Providing APIs to interact with Blockchain.
  2. Metamask(or any other blockchain enabling software): Allows for address management, signing transaction etc...

Metamask and other blockchain enabling software injects an object to browser window object. i.e. web3.

If you see in Metamask you can select which network you want to connect to. When selected a network that is our current target blockchain network.

At the begining of execution of client application, we provide following informtion to web3 to target a specific contract on a specific network.

  1. Current Network Provider
  2. Contract ABI
  3. Contract Address over the network

Once we have these 3 elements web3 enables us to talk to that contract.

Here key software is Metamask which actually bridges the gap between client and blockchain network.

Behind the scene: Once a transaction is confirmed by metamask then that request is sent to a central node provider generally Infura service, which has nodes running for different network. These nodes then broadcast your message/tx to the network and thats how you reach to blockchain without actually running a node or downloading the blockchain.

Under the hood of Metamask It talks to any network of Ethereum via Infura provided API which ultimately broadcasts the tx/messages from nodes run/maintained by them.

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.