[TWIL] Week of June 02, 2024
![[TWIL] Week of June 02, 2024](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1718003180377%2F28c3bddc-a03a-4937-84b1-776600a54e9d.png&w=3840&q=75)
Search for a command to run...
![[TWIL] Week of June 02, 2024](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1718003180377%2F28c3bddc-a03a-4937-84b1-776600a54e9d.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, I mainly focused on integrating the smart contracts I deployed last week into our website. I didn't learn much new, so I'll share some useful knowledge I gained in the past that I haven't shared yet. Solidity Immutable Variable While I was...
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 was the first full week of the Onchain Summer Buildathon. I signed up to participate, motivating myself to improve the UX on our platform and build great new features. To start, I upgraded a few npm packages to support the Base network and the Smart Wallet launched by the Coinbase Wallet team. Here are some of the things I learned along the way.
I had to upgrade Wagmi from version V1 to V2. While the complete list of changes is documented here, the information on handling TypeScript types was somewhat lacking in detail.
Wagmi Core Method Types
Besides React hooks, Wagmi also provides regular async methods, such as sendTransaction, powered by a package called viem. In V2, you can also import and use TypeScript types for parameters and return types. However, you need to specify the config type you're using for the generics. Here's an example:
import { type SendTransactionParameters, sendTransaction } from "@wagmi/core";
const config = createConfig({
// ...
});
export default async function sendWagmiTransaction(
args: SendTransactionParameters<typeof config>,
) {
const hash = await sendTransaction(config, args);
return hash;
}
useWaitForTransactionReceipt Type
Parsing transaction receipt logs is a common task for dapps, and I've been using useWaitForTransactionReceipt, the hook to retrieve the transaction receipt. In V2, you can use WaitForTransactionReceiptData, which is the data type returned by useWaitForTransactionReceipt. Here's how to use it:
const chains = [
mainnet,
sepolia,
goerli,
polygon,
polygonAmoy,
base,
baseSepolia,
] as const;
const chainIds = chains.map(({ id }) => id);
type ChainIds = typeof chainIds;
const config = createConfig({
// ...
});
async function parseTxReceiptData(
data: WaitForTransactionReceiptData<typeof config, ChainIds[number]>
) {
// ...
}
async function main() {
const { data } = useWaitForTransactionReceipt({ hash: "<tx-hash>" });
const parsedData = await parseTxReceiptData(data);
}
Instead of just passing in config, you also need to pass in a union of all the chain IDs that config supports.
Ethers is another package I had to upgrade due to a conflict with Next 14. I was setting up a JSON RPC provider for all the chains we support, but it kept giving me an error message: Could not detect network. I discovered that ethers V5 has an issue with Next 14, which left me with two options:
Keep ethers V5 and implement a temporary workaround
Upgrade to ethers V6 and make the necessary changes to the codebase
Since I was using wagmi, there wasn't much use of ethers in the codebase, so I chose the second option. If you ever need to use ethers with Next 14, make sure your ethers package is V6 or higher.
That's it for this week. For the next few weeks, I'll be deeply focused on modifying and building new features for the Buildathon. After that, I'll share what I've learned. Happy hacking, everyone ☕️