Definition of Application Binary Interface (ABI) of a smart contract and how to find it
The Application Binary Interface (ABI) of a smart contract describes the functions available to call in the smart contract. This includes the arguments that should be sent as well as the type of value the contract is expecting. This information is stored in JSON format and provides a readable definition of the function(s) within the contract.
Let’s take a look at an example mint function in Solidity:
The logic is purposefully kept simple. The important part to understand is that this mint function accepts two parameters named _to and _quantity. The type that is expected precedes their name.
Now let’s look at the section of the contract ABI that describes this function:
You can see that the inputs attribute of this JSON object describes the expected parameters and lists the type of value that is expected. This is important to be able to send valid transactions to the smart contract. Crossmint constructs and sends transactions to your contract, which is why we need the ABI.
If the contract is verified or published on the explorer
The easiest and most reliable way to find the ABI for your smart contract is to ensure your contract is published and verified on the block explorer. When this is the case we will automatically retrieve the ABI for your smart contract as soon as you input the contract address in the dev console.
If the contact is not verified or published on the explorer
Before we explain another way to find the ABI please understand verifying and publishing the contract source code is beneficial for additional reasons.
It is possible to manually add the ABI to our developer console if you’re not able to publish and verify the contract source code. Part of the contract deployment process includes compiling source code to bytecode. This step also creates the JSON representation, which you can use for completing contract registration in the Crossmint Dev Console.
The Crossmint Dev Console will accept the entire ABI or just the specific section related to the mint function that you’re registering. When you enter it into our dev console it should include the enclosing square brackets. Below is an example of what this looks like:
After entering the ABI correctly our interface will attempt to automatically identify the valid mint functions and fill them into the dropdown for you to select. You must double check that the correct function arguments are selected for the recipient address and NFT purchase quantity fields.
That’s all there is to it! With your contract registered you can add our payments button to your website to begin accepting credit card and cross-chain payments for your mint. You can find more information on contract registration in our documentation section here.
Then checkout the steps to add the payment button here.
If you have more questions feel free to ask our support team, which is available for you 24 hours a day, 7 days of the week.
If you're an individual course creator who wants to start issuing NFTs for your courses, then this guide is for you.
If you're a university professor who wants to quickly start issuing NFTs to your students, then this is for you.