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.
ETH vs WETH: Understanding the Difference and Their Roles in Ethereum
- Transaction Fees: ETH is required to pay gas fees, which are used to process transactions and execute smart contracts on the Ethereum network.
- Store of Value: ETH, like Bitcoin, is often used as a store of value or an investment asset.
- Participating in dApps: ETH is essential for interacting with decentralized applications (dApps) that run on the Ethereum network.
WETH (Wrapped Ether) is a token that represents an ERC-20 standard version of ETH. While ETH is the core currency of the Ethereum blockchain, it is not compatible with the ERC-20 standard, which governs the majority of tokens on the Ethereum network. This is where WETH comes into play.
Writing an ERC-20 Token Contract with OpenZeppelin
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);
const MyToken = await ethers.getContractFactory("MyToken");
const myToken = await MyToken.deploy("MyToken", "MTK", ethers.utils.parseUnits("1000000", 18));
console.log("MyToken deployed to:", myToken.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});- getSigners: Retrieves the list of accounts provided by the Ethereum node, with the first account used as the deployer.
- getContractFactory: Gets the contract to deploy.
- deploy: Deploys the contract with the specified parameters (name, symbol, and initial supply).
- parseUnits: Converts the initial supply to the correct units, considering the token’s decimals.