KYC

Know Your Customer (KYC) is required in Maxonrow blockchain. All wallets, tokens, and administrative operations (e.g., transaction) are required to undergo a KYC process and be verified by three parties (i.e., provider, issuer, and middleware) beforehand. Only verified wallets, tokens, and administrative operations (e.g, transaction) are allowed to proceed and participate in the blockchain.

Administrative operations (e.g., transaction) must first signed by provider, then issuer, and lastly by middleware

Creating Instances

Kyc . create ( signerOrProvider )   => Promise<Kyc>
Creates a new instance reference from signerOrProvider and connect to a provider (optional).
create an instance of KYC with reference from provider
let wallet = new mxw.Wallet(0x00000000000000000000000000000000000000000000000070726f7669646572, networkProvider);
let kyc = auth.Kyc.create(wallet);

Signing

prototype . getKycAddress ( keyComponent )   => string

Computes KYC address from key components by SHA2-256 cryptographic hash and converts into Bech32 format.

The valid key components are:

  • country — the country code of issuer
  • idType — the identification document type
  • id — the identification number of the applicant
  • idExpiry — the expire date (YYYYMMDD) of the identification document, in number
  • dob — the applicant’s date of birth (YYYMMDD), in number
  • seed — additional value to stir into the hashing

If the seed is not specified, it should be defaulted to 32 bytes of zero.

prototype . sign ( keyComponentOrAddress )   => Promise<KycData>
Signs KycAddress and returns a Promise that resolves to the signed KYC Data. The JSON object should be sorted and signed by applicant’s wallet.
generate KYC address and sign
    //create a new wallet to
    let networkProvider = mxw.getDefaultProvider("localnet");
    var wallet = mxw.Wallet.createRandom().connect(networkProvider);
    auth.Kyc.create(wallet).then((kycR)=>{
        let seed = sha256(toUtf8Bytes(JSON.stringify(sortObject({
            juridical: ["", ""].sort(),
            seed: utils.getHash(utils.randomBytes(32))
        }))));

        let kycAddress = kycR.getKycAddress({
            country: "MY",
            idType: "NIC",
            id: wallet.address,
            idExpiry: 20200101,
            dob: 19800101,
            seed
        });

        console.log("KYC Address: " + kycAddress);
        //expected result:
        //kyc1ekv4s2e75vyzmjjnve3md9ek5zm3pt66949vclrttgkfrrc6squqlxlpsp

        return kycR.sign(kycAddress).then((data) => {
            console.log(JSON.stringify(data));
        });
        //expected result:
        //KYC Data, click on the link above for more information

});
prototype . signTransaction ( transaction )   => Promise<KycTransaction>
Signs transaction and returns a Promise that resolves to the signed transaction. The transaction should be signed by KYC provider or KYC issuer.
prototype . approve ( transaction )   => Promise<TransactionReceipt>

Sends the signedTransaction to the entire blockchain network and returns a Promise that resolves to the Transaction Receipt. The transaction should be signed by KYC middleware.

If an error occurs after the network may have received the transaction, the promise will reject with the error, with the additional property transactionHash so that further processing may be done.

prototype . revoke ( address, signer )   => Promise<KycStatusTransaction>
Signs transaction and returns a Promise that resolves to the signed transaction. The transaction should be signed by KYC provider.
prototype . signStatusTransaction ( transaction, signer )   => Promise<KycStatusTransaction>
Signs transaction and returns a Promise that resolves to the signed transaction. The transaction should be signed by KYC provider or KYC issuer.
prototype . sendStatusTransaction ( transaction, signer )   => Promise<TransactionReceipt>

Sends the signedTransaction to the entire blockchain network and returns a Promise that resolves to the Transaction Receipt. The transaction should be signed by KYC middleware.

If an error occurs after the network may have received the transaction, the promise will reject with the error, with the additional property transactionHash so that further processing may be done.

Miscellaneous

wallet . isWhitelisted ( )   => Promise<Boolean>
Returns a Promise of the wallet’s whitelist status and queries KYC whitelist status by wallet address.
check if the wallet is whitelisted
let privateKey = "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
let networkProvider = mxw.getDefaultProvider("localnet");
let wallet = new mxw.Wallet(privateKey, networkProvider);
wallet.isWhitelisted().then((result)=>{
    console.log(result);
});
// expected result:
// true or false
prototype . bind ( AddressOrName, kycAddress, signer )   => Promise<TransactionReceipt>

Creates relationship between wallets by sending kycBind transaction to the entire blockchain network and returns a Promise that resolves to the Transaction Receipt. The transaction should be signed by the initiator.

The AddressOrName can be set to target alias or wallet address. The kycAddress is the reference of relationship.

bind whitelisted wallet
let otherWalletAddress = mxw1duct5rv3wan3vpdk3ms6kgn0j8h905kqvccw4r;
let otherKycAddress = auth.Kyc.create(otherWalletAddress).getKycAddress(otherWalletAddress);
let myWallet = new mxw.Wallet(0x00000000000000000000000000000000000000000000000070726f7669646572, networkProvider);
let myKyc = auth.Kyc.create(myWallet);
let receipt = myKyc.bind(walletAddress, kycAddress, myWallet);
console.log(receipt.status)
//expected result:
//1 (successfully bind)
prototype . unbind ( AddressOrName, kycAddress, signer )   => Promise<TransactionReceipt>

Removes relationship between wallets by sending kycUnbind transaction to the entire blockchain network and returns a Promise that resolves to the Transaction Receipt. The transaction should be signed by initiator.

The AddressOrName can be set to target alias or wallet address. The kycAddress is the reference of relationship.

unbind whitelisted wallet
let otherWalletAddress = mxw1duct5rv3wan3vpdk3ms6kgn0j8h905kqvccw4r;
let otherKycAddress = auth.Kyc.create(otherWalletAddress).getKycAddress(otherWalletAddress);
let myWallet = new mxw.Wallet(0x00000000000000000000000000000000000000000000000070726f7669646572, networkProvider);
let myKycWallet = auth.Kyc.create(myWallet);
let receipt = myKycWallet.unbind(walletAddress, kycAddress, myWallet);
console.log(receipt.status)
//expected result:
//1 (successfully unbind)