Create an account or log in

Keep learning for free! Join and start boosting your career

Aprovecha el precio especial y haz tu profesión a prueba de IA

Antes: $249

Currency
$209
Suscríbete

Termina en:

0 Días
10 Hrs
55 Min
7 Seg

¿Qué es Web3?

4/23
Resources

What is Web3 and why is it crucial for Blockchain transactions?

Web3 is a must-have tool if you are getting into the world of decentralized applications and Blockchain transactions. This ecosystem is designed to facilitate access and communication with Ethereum Virtual Machine (EVM) compatible networks. By using Web3, you will be able to translate interactions from the front-end to the calls you make through transactions on the Blockchain.

Why use Web3?

  • Automation: Web3 automates the connection to the Blockchain through transactions that will facilitate interactions from the front-end of your application.

  • Broad compatibility: Although many libraries are related to Ethereum, Web3 is compatible with any network that supports the Ethereum Virtual Machine, making it a versatile solution for different projects.

  • Useful sub-libraries: It offers a wealth of sub-libraries for various purposes beyond Ethereum, as well as tools to decentralize storage and communication systems.

What are the libraries available in Web3?

Web3 encompasses several libraries that fall into different categories:

  • .eth library: works with Ethereum-related methods.
  • Protocols such as Whisper and Swarm: Although not covered in this course, they are fundamental for decentralizing the web, managing communications and storage.
  • Punto Net Library: Includes functionalities such as digital signatures and wallet access control, crucial for signing transactions.
  • Contracts Library: Allows the instantiation of smart contracts and facilitates direct communication with them, using HTTP or WebSocket protocols.

How to configure a project with Web3 JS?

Step by step: Installation and basic configuration

  1. Create a development environment: Use a platform like Replit to start a NodeJS project quickly without too much initial configuration.
  2. Install the Web3 library: Select Web3 in the NodeJS packages section and install it. This process may take some time due to the included sublibraries and cryptographic utilities.
  3. Web3 instance: Use a provider, such as MetaMask or Infiura, to add an endpoint that connects to an Ethereum node.
const Web3 = require('web3');constweb3 = new Web3('https://mainnet.infura.io/v3/YOUR_PROJECT_ID');

Practical example: Get the current block number.

You can leverage the Web3 API to perform queries on the network, such as getting the current block in the Ethereum network:

web3.eth.getBlockNumber().then((number) => { console.log("Current block number:", number);});

With this function, you will be able to know the last block processed in Ethereum, validating the response obtained with services such as Etherscan.

How to make sure that a DApp works properly?

Web3, in conjunction with providers such as MetaMask, will allow you to validate permission requests and handle authentications. This is imperative to the success of any decentralized application by ensuring secure communication with the Blockchain.

Practical advice:

  • Always use up-to-date and secure endpoints.
  • Review the official Web3JS documentation to fully exploit its functionalities.
  • Use tools such as MetaMask to manage authentication and permissions.

As you progress, continuing to use Web3 will be essential for communication and data management in Blockchain applications. Always make sure to keep your skills up to date and explore more complex examples to broaden your knowledge in decentralized development - keep expanding your horizons!

Contributions 12

Questions 0

Sort by:

Want to see more contributions, questions and answers from the community?

La librería Web3.js es una colección de módulos que contienen funcionalidad para el ecosistema ethereum. Esta compuesta por:

  • web3-eth es para interactuar con la blockchain ethereum y los smart contracts
  • web3-shh es para interactuar con el protocolo whisper y comunicar p2p y broadcast
  • web3-bzz es para el protocolo swarm, el guardado de archivos descentralizado
  • web3-utils contiene funciones “helper” (de ayuda) para desarrolladores de Dapps

Fuente https://web3js.readthedocs.io/en/v1.2.11/getting-started.html

Mi código

const Web3 = require('web3');
const endpoint = "https://mainnet.infura.io/v3/..."
const web3 = new Web3(endpoint);

console.log(web3);

web3.eth.getBlockNumber().then(number => {
  console.log(number);
})

algo que mi mente no podia procesar cuando lo vi fue que podia hacer myPromise().then(console.log) si el resultado que regresaba la promesa solo lo queria mostrar en console.

antes hacia cosas como myPromise().then(res => console.log(res)) y tambien es valido. pero cuando aprendi esa alternativa me senti el doble de pro. 😅

Algun alma caritativa que tenga un endpoint en funcionamiento para compartir ?
el endpoint del projecto del profesor le pega a un projecto inactivo

No conocía replit, excelente aporte, gracias!

Aqui bloque 14250870!

¡Este profe es un crack!

me encanta este curso muy buena explicacion

Bloque 15361427

Mi bloque es 11104877!

Bloque 15005313

Por aquí en el bloque 14976914

bloque 15373511