Inspect Your Contract's ABI

Noah Hein
InstructorNoah Hein
Share this video with your friends

Social Share Links

Send Tweet
Published 2 years ago
Updated 2 years ago

You will learn how to inspect the Application Binary Interface — commonly referred to as ABI — of your smart contract. ABI's are generated whenever your contract is complied. It is the source of truth for how the contract expects information flowing into it to be shaped. You need the ABI to take a look at how to send transactions to and from a smart contract.

forge book reference

Instructor: [0:01] To interact with our newly deployed smart contract, we will use another tool that we installed from Foundry, which is Cast. In order to use Cast, we need to know the shape of the contract that we are going to be interacting with. We need to get what's called the ABI from our smart contract. [0:21] An ABI stands for Application Binary Interface. In the same way that you interact with APIs, an ABI is the same idea, but for a smart contract instead of a particular programming interface.

[0:36] To get the ABI for our smart contract, we use Forge. Forge has an inspect tool that lets you get various information for any particular contract. We can use forge inspect Number. It knows to look in source and then go through the contracts to find the particular contract that you have.

[0:56] We will forge inspect Number. Then it takes another argument. In our case, we want the ABI.

[1:04] There's many different options that you can pass here. You can look in the Forge book to find an exhaustive reference list of all of the different options that forge inspect has.

[1:15] You can see here it spits out a big blob. This is essentially our contract in a program. You can see here it's a big JSON blob. It has a list of inputs. You can see here that we have the name _num as uint256. Here you can see the type that it is. In this case, this is our constructor that we're looking at in this particular input right here.

[1:43] This gives us all of the information that we need to actually start sending transactions to and from our local chain.

egghead
egghead
~ 12 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today