Skip to main content

Don't have an API key yet?

Sign-up to Moralis to get your free API key and start building today.

Get Your Free API Key
Version: 2.2

How to get the spender allowance of an ERC20 token

Step 1: Setup Moralis

Read the article Setting Up Moralis: Getting Started and make sure to finish all the steps. Only after that you can go ahead to complete this guide.

Step 2: Get the spender allowance of an ERC20 token

In order to get the spender allowance, Moralis provides you with an getTokenAllowance endpoint.

Here you'll need four parameters: address , chain, ownerAddress , spenderAddress.

  • address: The address of the token contract.
  • chain: The chain to query.
  • ownerAddress: The address of the token owner.
  • spenderAddress: The address of the token spender.

Once you have obtained the parameters, you can copy the following code:

const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/common-evm-utils");

const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration

const chain = EvmChain.ETHEREUM;

const address = "0x514910771AF9Ca656af840dff83E8264EcF986CA";

const ownerAddress = "0x7c470D1633711E4b77c8397EBd1dF4095A9e9E02";

const spenderAddress = "0xed33259a056f4fb449ffb7b7e2ecb43a9b5685bf";

const response = await Moralis.EvmApi.token.getTokenAllowance({



Step 3: Run the script

To run the script, enter the following command:

node index.js

In your terminal, you should see the following JSON response:

"allowance": "0"

Congratulations 🥳 You just got the spender allowance with just a few lines of code using the Moralis Token API!

API Reference

If you want to know more details on the endpoint and optional parameters, check out:


If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.