Blockchain Development Programming Tutorials, Guides & Best Practices
Explore 30+ expertly crafted blockchain development tutorials, components, and code examples. Stay productive and build faster with proven implementation strategies and design patterns from DeveloperBreeze.
Adblocker Detected
It looks like you're using an adblocker. Our website relies on ads to keep running. Please consider disabling your adblocker to support us and access the content.
Understanding `crypto.randomBytes` and `ethers.randomBytes`: A Comparison
crypto.randomBytes:- Library:
crypto.randomBytesis part of Node.js’s built-incryptomodule. It requires no additional dependencies and is readily available in any Node.js environment. - Usage: The function takes a single argument specifying the number of bytes to generate and returns a
Bufferobject containing the random bytes. - Example:
const crypto = require('crypto');
const randomBytes = crypto.randomBytes(32);
console.log(randomBytes.toString('hex')); // Prints a 32-byte random hex stringHow to Query ERC-20 Token Balances and Transactions Using Ethers.js and Etherscan API
node getTokenTransactions.jsYou should see a list of token transactions for the specified address, with details including the sender, recipient, value transferred, and transaction hash.
Sending Transactions and Interacting with Smart Contracts Using Infura and Ethers.js
This output is the token balance in the smallest unit (e.g., Wei for Ether or the smallest denomination for the token), and you can convert it to the token’s base unit if needed.
Deploying smart contracts is a more advanced topic, but here’s an example of how you can use Ethers.js with Infura to deploy a smart contract:
Getting Wallet Balance Using Ethers.js in Node.js
To follow along, you’ll need the following:
- Node.js installed on your machine.
- Basic understanding of JavaScript.
- An Ethereum wallet (with private key or mnemonic phrase).
- (Optional) An Infura account to access the Ethereum network.
Blockchain Libraries Cheatsheet
- Description: A full-featured, open-source Bitcoin library for Node.js that allows you to build Bitcoin applications with ease.
- Use Cases:
- Build Bitcoin wallets and full-node implementations.
- Integrate Bitcoin functionality into existing Node.js applications.
- Develop custom Bitcoin transaction handling and mining scripts.
- Key Features:
- Full SPV and full-node support for Bitcoin.
- Modular architecture for building custom Bitcoin services.
- Detailed documentation and active community support.
- Installation:
npm install bcoin