Now that you have completed this course on using Hardhat for blockchain development, you are ready to take your skills to the next level. Here are some suggestions for what you can do next:
Practice and Improve your Skills
The best way to become proficient in any skill is to practice, practice, practice. Take the time to work on your own projects and try out different features and tools in Hardhat. You can also try completing online challenges or coding exercises to test your knowledge and skills.
Learn about other Blockchain Development Tools and Frameworks
Hardhat is just one of many tools available for blockchain development. Some other popular options include Truffle, Embark, and OpenZeppelin. Take the time to explore these tools and see how they compare to Hardhat. This will help you gain a better understanding of the blockchain development ecosystem and find the tools that work best for you.
Explore other Blockchain Platforms
In this course, we focused on using Hardhat with Ethereum. However, there are many other blockchain platforms out there, each with its own set of tools and features. Consider learning about other platforms such as EOS, Hyperledger Fabric, or Corda. This will give you the opportunity to expand your skill set and potentially open up new career opportunities.
Join a Community of Blockchain Developers
One of the best ways to learn and stay up-to-date with the latest developments in blockchain technology is to join a community of like-minded developers. There are many online forums, meetups, and groups where you can connect with other blockchain developers and share knowledge and experiences.
Keep Learning and Growing
Blockchain technology is constantly evolving, and it’s important to stay up-to-date with the latest developments. Consider taking additional courses or learning resources to continue improving your skills and knowledge. This will help you stay competitive in the fast-moving world of blockchain development.
Exercises
To review these concepts, we will go through a series of exercises designed to test your understanding and apply what you have learned.
Create a new Hardhat project and write a Solidity contract that defines a struct with three fields: a string, a uint, and a bool.
pragma solidity ^0.7.0;
contract StructContract {
struct MyStruct {
string name;
uint age;
bool isMale;
}
MyStruct myStruct;
constructor() public {
myStruct.name = "John Doe";
myStruct.age = 30;
myStruct.isMale = true;
}
}
Write a function that allows you to set the values of the struct.
pragma solidity ^0.7.0;
contract StructContract {
struct MyStruct {
string name;
uint age;
bool isMale;
}
MyStruct myStruct;
constructor() public {
myStruct.name = "John Doe";
myStruct.age = 30;
myStruct.isMale = true;
}
function setStructValues(string memory _name, uint _age, bool _isMale) public {
myStruct.name = _name;
myStruct.age = _age;
myStruct.isMale = _isMale;
}
}
Write a migration script that deploys the contract and calls the function to set the values of the struct.
const StructContract = artifacts.require("StructContract");
module.exports = async function(deployer) {
await deployer.deploy(StructContract);
const structContract = await StructContract.deployed();
await structContract.setStructValues("Jane Doe", 25, false);
};
Write a Hardhat script that calls the function to retrieve the values of the struct and prints them to the console.
const StructContract = artifacts.require("StructContract");
module.exports = async function(callback) {
const structContract = await StructContract.deployed();
const structValues = await structContract.myStruct();
console.log(structValues);
};
Modify the Solidity contract to add a mapping from addresses to structs. Write a function that allows you to set the values of the struct for a given address.
pragma solidity ^0.7.0;
contract StructContract {
struct MyStruct {
string name;
uint age;
bool isMale;
}
mapping(address => MyStruct) structs;
function setStructValues(address _address, string memory _name, uint _age, bool _isMale) public {
structs[_address].name = _name;
structs[_address].age = _age;
structs[_address].isMale = _isMale;
}
}