This repository contains Rust crate to resolve domains & addresses registered with AZERO.ID.
- Include this crate in the contract's
Cargo.toml
file.
// file: ./Cargo.toml
[dependencies]
azns-integration = { git = "https://github.com/azero-id/contract-integration", default-features = false }
[features]
std = [
"azns-integration/std",
..
]
- Store the router address and import the type
AccountIdOrDomain
// file: ./lib.rs
#[ink::contract]
mod example {
// 1. Import `AccountIdOrDomain` type
use azns_integration::AccountIdOrDomain;
#[ink(storage)]
pub struct Example {
// 2. Store AZERO-ID's router-contract address
domain_router: AccountId,
}
impl Example {
#[ink(constructor)]
pub fn new(domain_router: AccountId) -> Self {
Self { domain_router }
}
/// Returns the AccountId associated with the `user`
#[ink(message)]
pub fn simple_integration(&self, user: AccountIdOrDomain) -> Option<AccountId> {
user.get_address(self.domain_router) // Resolves user to AccountId
}
}
}
Refer to the sample example for more details.
View the full documentation & types here:
https://docs.azero.id/integration/contract-level
https://docs.azero.id/developers/deployments
- get_all_registries() -> Vec
- get_registry(tld: String) -> Option
- get_address(domain: String) -> Result<AccountId, u8>
- get_primary_domains(account: AccountId, tld: Option) -> Vec<(AccountId, String)>
Allows user to pass their AccountId
or their AZERO.ID Domain
pub enum AccountIdOrDomain {
AccountId(AccountId),
Domain(String),
}