New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Contract ABIs and Testing in Hardhat

BaseMon, Oct 9, 2023, 12:00 AM

Unlock the power of ABI (Application Binary Interface) in Ethereum development! Discover how it serves as the standard way to interact with contracts, enables smooth interaction with your contracts in various scenarios, and facilitates frontend development with TypeScript's type generation. Unravel the mysteries of ABI for seamless contract interactions! 🔍🔄 📚 Head to Base Camp for full courses on smart contract development: https://docs.base.org/base-camp/docs/welcome ✅ Subscribe to our channel here: https://www.youtube.com/@BuildonBase ► Build on Base: https://base.org ► Follow us on Twitter: https://twitter.com/buildonbase ► Join our Discord: https://base.org/discord

Transcript

the solidity docs describe the ABI as the standard way to interact with contracts in the ethereum ecosystem both from outside the blockchain and for contract to contract interaction in other words this is used as an interface for things like ethers.js to understand what functions and properties and values and variables you have in your contract and how to interact with them you can find the ABI looking under the artifacts folder under contracts and then for the name of the contract file and here we have lock.json for our lot contract at first the ABI looks a little bit jumbled but as we dig into it we can start to see things that are recognizable we have a Constructor here we have our deposit event that we created we have the withdrawal event and looking within these events you can see the inputs match what we have in the contract itself so in this case we have an input for a uint 256 that's named amount and looking at the withdrawal event we can see the same thing here we can also look down and find our function that we created the deposit function right here you can see that we have our deposit function which we created and it doesn't have any inputs but it is a payable function and we can see the state mutability is payable and its type is function the ABI is used for a number of things including the behind the scenes work that makes type chain function and lets you get intellisense when you're typing tests back in our test file you'll also use it in the future when you're developing a front end to tell that front end how to interact with your smart contract

Automatic transcript — names and jargon may be misspelled.