> For the complete documentation index, see [llms.txt](https://jungle-toolkit.gitbook.io/evm-xcm-jungle-toolkit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jungle-toolkit.gitbook.io/evm-xcm-jungle-toolkit/build-an-evm+substrate-wallet-compatible-architecture-in-your-dapp/the-substrate-address-standard/get-an-address-for-a-signer/check-the-validity-of-the-address.md).

# Check the validity of the address

## Checking the validity of a Substrate address using Polkadot utils

```javascript
// Import Polkadot.js API dependencies.
const { decodeAddress, encodeAddress } = require('@polkadot/keyring');
const { hexToU8a, isHex } = require('@polkadot/util');

// Specify an address to test.
const addressToTest = 'testAddy';

// Function to check the validity of a Substrate address.
const isValidSubstrateAddress = (address) => {
  try {
    // Decode the address if it's in hex format, otherwise, assume it's a raw address.
    const decodedAddress = isHex(address) ? hexToU8a(address) : decodeAddress(address);

    // Encode the address to check its validity.
    encodeAddress(decodedAddress);

    return true;
  } catch (error) {
    return false;
  }
};

// Call the function to check the validity of the specified address.
const isValid = isValidSubstrateAddress(addressToTest);

// Output the result.
console.log(`Is this Substrate address valid? ${isValid}`);

```
