[TWIL] Week of June 23, 2024
![[TWIL] Week of June 23, 2024](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1720503962128%2F4e8d0398-ab04-401b-8082-054fba4fe427.png&w=3840&q=75)
Search for a command to run...
![[TWIL] Week of June 23, 2024](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1720503962128%2F4e8d0398-ab04-401b-8082-054fba4fe427.png&w=3840&q=75)
No comments yet. Be the first to comment.
This series is about my weekly learning experiences, covering a broad range of topics with a focus on sharing engineering tips and techniques whenever possible.
This week marked the third week of the Onchain Summer Buildathon, where our focus was on refining our code to support interactions with Externally Owned Accounts (EOAs). Here’s a deep dive into what I learned and achieved during this week of building...
This year, I decided to attend ETHDenver, one of the most well-known crypto conferences in the world, from February 25th to March 1st. Although I wasn’t there for the entire week, I made it a priority to experience as much as possible within the few ...

AI has become an unavoidable topic in tech, with models like OpenAI’s ChatGPT, DeepSeek, and Gemini dominating headlines. Since ChatGPT’s release in November 2022, AI has rapidly changed how we work and build software. Naturally, I’ve been using it e...

Hello builders! I hope you all had a fantastic week. Mine was a bit more laid-back. I decided to turn off my "build mode" and dive into some reading. I picked up two books: one technical and one non-technical (though still focused on NFTs). In this p...
![[TWIL] Week of August 11, 2024](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1724192926501%2F2ba38d69-5f89-4c41-b2fe-7f994fa97f71.png&w=3840&q=75)
Hello Builders! Hope you had a wonderful week! For this week’s TWIL post, I’d like to share a slight change to the series moving forward. As I mentioned in my previous post, I’ll continue writing one TWIL post each week, but the content might shift a...
![[TWIL] Week of August 04, 2024](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1723410046529%2F77c9c1f6-e0e2-4422-aa2c-0b82b769631c.png&w=3840&q=75)
Hello builders! This past week has been one of the most emotionally charged experiences I've had in a while. After much thought, I've made the difficult decision to leave Ourkive, the startup I co-founded alongside two other incredible people. While ...
![[TWIL] Week of July 28, 2024](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1723335244607%2F22b5f8ee-4c35-4cf0-9666-405c09aae03c.png&w=3840&q=75)
This week marked the final phase of the Onchain Summer Buildathon, where I concentrated on refactoring code and introducing a new feature for artist and visual artist collaborations. Here are some key takeaways from my work:
Previously, artists on our web app followed these steps to mint a music NFT:
Click the "Release" button.
The button handler mints an NFT for the artist, approves the NFT marketplace smart contract to transfer the NFT, and lists the NFT on the marketplace.
The artist waits for all transactions to be validated.
Once validated, MongoDB is updated with relevant transaction details, such as the transaction hash.
This process was problematic because some artists would leave the page before transaction validation was complete. To address this issue, we needed a way to trigger a database update automatically in the background once the transaction was validated.
Fortunately, our web app uses Alchemy as the primary node provider. I discovered that Alchemy supports webhooks for various on-chain activities, such as address activity and NFT metadata updates. I opted for the NFT activity webhook, which sends transaction data to an API I created whenever an NFT transfer occurs.
I set up a webhook via the Alchemy web app so that once an NFT is minted, the transaction data is sent to the API. The API then extracts the necessary information from the request and updates the database. As a result, the new user flow is as follows:
Click the "Release" button.
The button handler mints an NFT for the artist, approves the NFT marketplace smart contract to transfer the NFT, and lists the NFT on the marketplace.
That's it! Artists no longer need to wait for transaction validation. An optimistic update is performed on the client side, while the Alchemy webhook handles transaction validation and database updates in the background.
There are other types of Alchemy webhooks available, so be sure to check out their official documentation for more details.
Starting from version 0.8.4, Solidity supports custom errors, which can be thrown using the revert keyword. Here's an example:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract Test {
error NotOwner(address notOwner);
address owner;
constructor() {
owner = msg.sender;
}
function checkAndGetOwner(
address addr
)
public
view
returns (address)
{
if (owner != addr) {
revert NotOwner(addr);
}
return owner;
}
}
The benefits of using a custom error are twofold: it is more gas-efficient and allows for the creation of dynamic error messages.
To test this code, you can use the revertedWithCustomError method from Chai.
import { ethers } from "hardhat";
import { expect } from "chai";
describe("Test", () => {
it("should throw error", async () => {
const [deployer, account] = await ethers.getSigners();
const test = await ethers.deployContract("Test");
await expect(test.checkAndGetOwner(account.address))
.to.be.revertedWithCustomError(test, "NotOwner")
.withArgs(account.address);
});
});
That's a wrap for this week! We've successfully completed and submitted our Onchain Summer Buildathon application. In the coming week, our focus will shift to refactoring a substantial amount of code. Stay tuned for more updates and happy hacking! ☕️