# NEAR

# Adding on-chain kycNFT checks

Our smart contract deployed on NEAR chain implements a very simple interface which implementing smart contracts can use to quickly check if a certain AccountID has a valid kycNFT.

/// A trait for checking whether an address has a valid kycNFT token
#[ext_contract(kycdao)]
trait KycValidity {
    /// Check if an account has any valid tokens
    fn has_valid_token(&self, address: AccountId) -> bool;
}

You can use the above function in a cross-contract call to check if a given AccountID has valid kycNFT.

# Example

Here is an example of a contract using a cross-contract call to check if the AccountId has a valid kycNFT token.

fn query_kyc(&self, account_id: AccountId) -> Promise {
    // Create a promise to call kycdao.has_valid_token()
    let promise = kycdao::ext(self.kyc_contract_address.clone())
      .with_static_gas(Gas(5*TGAS))
      .has_valid_token(account_id);
    
    return promise.then( // Create a promise to callback query_kyc_callback
      Self::ext(env::current_account_id())
      .with_static_gas(Gas(5*TGAS))
      .query_kyc_callback()
    )
}

#[private]
pub fn query_kyc_callback(&self, #[callback_result] call_result: Result<bool, PromiseError>) -> bool {
    if call_result.is_err() {
      log!("There was an error contacting KYC Contract");
      return false;
    }
    
    // Return the KYC validity, or do some gating with it
    let validity: bool = call_result.unwrap();
    validity
}

# Contract addresses

Blockchain Network Contract Address
NEAR Mainnet KYC app.kycdao.near
NEAR Testnet KYC app.kycdao.testnet