# principal

The `CandidType` object `Principal` corresponds to the Candid type principal, is inferred to be a TypeScript @dfinity/principal `Principal`, and will be decoded into an @dfinity/principal Principal at runtime.

TypeScript or JavaScript:

    import { Canister, Principal, query } from 'azle';

    export default Canister({
        getPrincipal: query([], Principal, () => {
            return Principal.fromText('rrkah-fqaaa-aaaaa-aaaaq-cai');
        }),
        printPrincipal: query([Principal], Principal, (principal) => {
            console.log(typeof principal);
            return principal;
        })
    });

Candid:

    service : () -> {
        getPrincipal : () -> (principal) query;
        printPrincipal : (principal) -> (principal) query;
    }

dfx:

    dfx canister call candid_canister printPrincipal '(principal "rrkah-fqaaa-aaaaa-aaaaq-cai")'
    (principal "rrkah-fqaaa-aaaaa-aaaaq-cai")