DeveloperBreeze

Ethereum Development Tutorials, Guides & Insights

Unlock 16+ expert-curated ethereum tutorials, real-world code snippets, and modern dev strategies. From fundamentals to advanced topics, boost your ethereum skills on DeveloperBreeze.

Understanding `crypto.randomBytes` and `ethers.randomBytes`: A Comparison

Tutorial October 24, 2024

Both crypto.randomBytes and ethers.randomBytes generate cryptographically secure random bytes, meaning the bytes are suitable for use in cryptographic applications such as key generation, encryption, and other security-sensitive operations.

  • Use crypto.randomBytes when:
  • You are building Node.js applications without blockchain-specific functionality.
  • You want to avoid adding external dependencies.
  • Use ethers.randomBytes when:
  • You are developing Ethereum-related applications and already have ethers.js in your project.
  • You want the flexibility of generating random bytes with minimal configuration, defaulting to 32 bytes for Ethereum addresses or private keys.

How to Query ERC-20 Token Balances and Transactions Using Ethers.js and Etherscan API

Tutorial October 24, 2024

You should see a list of token transactions for the specified address, with details including the sender, recipient, value transferred, and transaction hash.

You can customize the Etherscan API request to suit your needs. Here are a few options:

Etherscan vs Infura: Choosing the Right API for Your Blockchain Application

Tutorial October 24, 2024

In some cases, you might want to use both Etherscan and Infura. For example, you might use Etherscan to query transaction histories or token transfers, and Infura to send transactions or deploy contracts.

  • Etherscan: Use to fetch transaction history and display it in your dApp.
  • Infura: Use to allow users to send transactions or interact with smart contracts.

Sending Transactions and Interacting with Smart Contracts Using Infura and Ethers.js

Tutorial October 24, 2024

Transaction sent: 0xTransactionHash
Transaction confirmed: { transaction details }

Next, let’s interact with a smart contract using Ethers.js and Infura. For this example, we will call a read-only function from an ERC-20 token contract (like querying the balance of a wallet).

Understanding and Using the Etherscan API to Query Blockchain Data

Tutorial October 24, 2024

We will use Axios to make HTTP requests to the Etherscan API. To install Axios, run the following command in your project folder:

npm install axios