Skip to content

Working with delegates

luiziov42 edited this page Oct 9, 2020 · 20 revisions

Working with delegates

Delegate is an iov42 feature that enables an identity to act on behalf of another. A delegate can perform any actions that the identity itself is allowed to perform.

Adding delegate to an identity

The method addDelegate adds a delegate to an identity.

import { IKeyPairData, PlatformClient, IAuthorisedRequest, IAddDelegateRequest } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);

const keyPair: IKeyPairData = "<previously generated key pair>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair>";
const identityId: string = "<existing identityId>";
const delegateIdentityId: string = "<existing identityId>";

const request: IAddDelegateRequest = {
    _type: "AddDelegateRequest",
    delegateIdentityId,
    delegatorIdentityId: identityId,
    requestId: uuidv4(),
};
const signedRequest: IAuthorisedRequest = platformClient.prepareRequest(request, keyPair);
const finalRequest: IAuthorisedRequest = platformClient.addSignatureRequest(
    signedRequest,
    delegateKeyPair
);

platformClient.addDelegate(finalRequest, keyPair)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving identity's delegates

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);

const keyPair: IKeyPairData = "<previously generated key pair>";
const identityId: string = "<existing identityId>";

platformClient.getDelegates(identityId, keyPair);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Creating an asset type via delegate

The method createAssetType creates an asset type, and can be triggered by an identity's delegate.

import { IKeyPairData, PlatformClient, IAuthorisedRequest, IAddDelegateRequest } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);

const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const request: ICreateAssetTypeRequest = {
    assetTypeId: uuidv4(),
    type: "Unique",
    requestId: uuidv4(),
};

platformClient.createAssetType(request, delegateKeyPair, delegatorIdentityId)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Reading an asset type via delegate

The method getAssetType reads an asset type in the iov42 platform, and can be triggered by an identity's delegate.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);

const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const assetTypeId: string = "<existing assetTypeId, owned by delegatorIdentityId>";
platformClient.getAssetType(assetTypeId, keyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Creating an asset/account via delegate

The helper method createAsset creates a new quantifiable asset/account.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const quantifiableAssetTypeId = "<existing quantifiable asset type>"
const request: ICreateAssetRequest = {
    assetId: uuidv4(),
    assetTypeId: quantifiableAssetTypeId,
    quantity: "100",
    requestId: uuidv4(),
}

platformClient.createAsset(request, keyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Reading an asset/account using delegate

The method getAsset reads an asset/account in the iov42 platform.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);

const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const assetId: string = "<existing assetId>";
platformClient.getAsset(assetId, keyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Adding quantity to balance of a quantifiable asset/account using delegate

The helper method addAssetQuantity adds a quantity to a quantifiable asset/account.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const quantifiableAssetTypeId = "<existing quantifiable asset type>";
const accountId = "<existing accountId for quantifiableAssetTypeId>";
const request: ICreateAssetRequest = {
    assetId: accountId,
    assetTypeId: quantifiableAssetTypeId,
    quantity: "100",
    requestId: uuidv4(),
}

platformClient.addAssetQuantity(request, keyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Creating claims for an identity using delegate

The helper method createIdentityClaims creates claims for an identity.

import { ICreateClaimsRequest, IKeyPairData, PlatformClient, PlatformUtils } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const platformUtils = new PlatformUtils();
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const claims: string[] = "array of claims";
const request: ICreateClaimsRequest = {
    claims: platformUtils.createClaimsHashArray(claims),
    requestId: uuidv4(),
    subjectId: delegatorIdentityId,
};
platformClient.createIdentityClaims(request, claims, delegateKeyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving all claims of an identity using delegate

The helper method getIdentityClaims retrieves all claims of an identity.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";

platformClient.getIdentityClaims(delegatorIdentityId, delegateKeyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving a single claim of an identity using delegate

The helper method getIdentityClaim retrieves a single claim of an identity.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const claimHash: string = "<sha256 hash of the claim>";

platformClient.getIdentityClaim(delegatorIdentityId, claimHash, keyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Creating claims for an asset type using delegate

The helper method createAssetTypeClaims creates claims for an asset type.

import { ICreateClaimsRequest, IKeyPairData, PlatformClient, PlatformUtils } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const platformUtils = new PlatformUtils();
const assetTypeId: string = "<existing assetTypeId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const claims: string[] = "array of claims";
const request: ICreateClaimsRequest = {
    claims: platformUtils.createClaimsHashArray(claims),
    requestId: uuidv4(),
    subjectId: assetTypeId,
};
platformClient.createAssetTypeClaims(request, claims, delegateKeyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving all claims of an asset type using delegate

The helper method getAssetTypeClaims retrieves all claims of an asset type.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const assetTypeId: string = "<existing assetTypeId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";

platformClient.getAssetTypeClaims(assetTypeId, delegateKeyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving a single claim of an asset type using delegate

The helper method getAssetTypeClaim retrieves a single claim of an asset type.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const assetTypeId: string = "<existing assetTypeId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const claimHash: string = "<sha256 hash of the claim>";

platformClient.getAssetTypeClaim(assetTypeId, claimHash, delegateKeyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Creating claims for an asset/account using delegate

The helper method createAssetClaims creates claims for an asset/account.

import { ICreateClaimsRequest, IKeyPairData, PlatformClient, PlatformUtils } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const platformUtils = new PlatformUtils();
const assetId: string = "<existing assetId or accountId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const claims: string[] = "array of claims";
const request: ICreateClaimsRequest = {
    claims: platformUtils.createClaimsHashArray(claims),
    requestId: uuidv4(),
    subjectId: assetId,
};
platformClient.createAssetClaims(request, claims, delegateKeyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving all claims of an asset/account using delegate

The helper method getAssetClaims retrieves all claims of an asset/account.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const assetId: string = "<existing assetId or accountId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";

platformClient.getAssetClaims(assetId, delegateKeyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving a single claim of an asset/account using delegate

The helper method getAssetClaim retrieves a single claim of an asset/account.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const assetId: string = "<existing assetId or accountId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of delegatorIdentityId>";
const delegatorIdentityId: string = "<existing identityId>";
const claimHash: string = "<sha256 hash of the claim>";

platformClient.getAssetClaim(assetId, claimHash, delegateKeyPair, delegatorIdentityId);
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Creating endorsements for identity's claims using delegate

The helper method endorseIdentityClaims endorses claims for an identity.

import { ICreateClaimsRequest, IKeyPairData, PlatformClient, PlatformUtils } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const platformUtils = new PlatformUtils();
const identityId: string = "<existing identityId>";
const endorserId: string = "<existing identityId>";
const keyPair: IKeyPairData = "<previously generated key pair>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of endorserId>";
const claims: string[] = "array of claims";
const endorsements = platformUtils.createEndorsementsObject(
    identityId,
    claims,
    delegateKeyPair);
const request: IEndorseClaimsRequest = {
    _type: "CreateIdentityEndorsementsRequest",
    endorserId,
    endorsements,
    requestId: uuidv4(),
    subjectId: identityId,
}
const signedRequest: IAuthorisedRequest = platformClient.prepareRequest(request, keyPair);
const finalRequest: IAuthorisedRequest = platformClient.addSignatureRequest(
    signedRequest,
    delegateKeyPair,
    endorserId,
);
platformClient.endorseIdentityClaims(finalRequest, claims, delegateKeyPair)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving an endorsement for an identity's claim using delegate

The helper method getIdentityClaimEndorsement retrieves the endorsement for an identity's claim.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const identityId: string = "<existing identityId>";
const endorserId: string = "<existing identityId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of endorserId>";
const claimHash: string = "<sha256 hash of the claim>";

platformClient.getIdentityClaimEndorsement(
                    identityId,
                    claimHash,
                    endorserId,
                    delegateKeyPair,
                    endorserId)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Creating endorsements for asset type's claims using delegate

The helper method endorseAssetTypeClaims creates claims for an asset type.

import { ICreateClaimsRequest, IKeyPairData, PlatformClient, PlatformUtils } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const platformUtils = new PlatformUtils();
const assetTypeId: string = "<existing assetTypeId>";
const keyPair: IKeyPairData = "<previously generated key pair>";
const endorserId: string = "<existing identityId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of endorserId>";
const claims: string[] = "array of claims";
const endorsements = platformUtils.createEndorsementsObject(
    assetTypeId,
    claims,
    delegateKeyPair);
const request: IEndorseClaimsRequest = {
    _type: "CreateAssetTypeEndorsementsRequest",
    endorserId,
    endorsements,
    requestId: uuidv4(),
    subjectId: assetTypeId,
}
const signedRequest: IAuthorisedRequest = platformClient.prepareRequest(request, keyPair);
const finalRequest: IAuthorisedRequest = platformClient.addSignatureRequest(
    signedRequest,
    delegateKeyPair,
    endorserId,
);
platformClient.endorseAssetTypeClaims(finalRequest, claims, delegateKeyPair)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving an endorsement for an asset type's claim using delegate

The helper method getAssetTypeClaimEndorsement retrieves a single claim of an asset type.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const assetTypeId: string = "<existing assetTypeId>";
const keyPair: IKeyPairData = "<previously generated key pair>";
const endorserId: string = "<existing identityId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of endorserId>";
const claimHash: string = "<sha256 hash of the claim>";

platformClient.getAssetTypeClaimEndorsement(
                    assetTypeId,
                    claimHash,
                    endorserId,
                    delegateKeyPair,
                    endorserId)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Creating endorsements for asset's or account's claims using delegate

The helper method endorseAssetClaims creates claims for an asset/account.

import { ICreateClaimsRequest, IKeyPairData, PlatformClient, PlatformUtils } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const platformUtils = new PlatformUtils();
const assetId: string = "<existing assetId or accountId>";
const assetTypeId: string = "<assetTypeId of assetId or accountId>";
const keyPair: IKeyPairData = "<previously generated key pair>";
const endorserId: string = "<existing identityId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of endorserId>";
const claims: string[] = "array of claims";
const endorsements = platformUtils.createEndorsementsObject(
    assetId,
    claims,
    delegateKeyPair,
    assetTypeId);
const request: IEndorseClaimsRequest = {
    _type: "CreateAssetEndorsementsRequest",
    endorserId,
    endorsements,
    requestId: uuidv4(),
    subjectId: assetId,
    subjectTypeId: assetTypeId,
}
const signedRequest: IAuthorisedRequest = platformClient.prepareRequest(request, keyPair);
const finalRequest: IAuthorisedRequest = platformClient.addSignatureRequest(
    signedRequest,
    delegateKeyPair,
    endorserId,
);
platformClient.endorseAssetClaims(finalRequest, claims, delegateKeyPair)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieving an endorsement for an asset's or account's claim using delegate

The helper method getAssetClaimEndorsement retrieves a single claim of an asset/account.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const assetId: string = "<existing assetId or accountId>";
const assetTypeId: string = "<assetTypeId of assetId or accountId>";
const keyPair: IKeyPairData = "<previously generated key pair>";
const endorserId: string = "<existing identityId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of endorserId>";
const claimHash: string = "<sha256 hash of the claim>";

platformClient.getAssetClaimEndorsement(
                    assetId,
                    assetTypeId,
                    claimHash,
                    endorserId,
                    delegateKeyPair,
                    endorserId)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Transfer of unique asset using delegate

The helper method transferAssets transfers an unique asset between identities.

import { IKeyPairData, PlatformUtils } from "../iov42/core-sdk";

const platformUtils = new PlatformUtils ();
const keyPair1: IKeyPairData = "<previously generated key pair>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of identity1>";
const identityId1: string = "<existing identityId>";
const identityId2: string = "<existing identityId>";
const uniqueAssetTypeId: string = "<existing assetTpeId>";
const uniqueAssetId: string = "<unique assetId belonging to identity1>";
const transfer: ITransferOwnership = {
    assetId: uniqueAssetId,
    assetTypeId: uniqueAssetTypeId,
    fromIdentityId: identityId1,
    toIdentityId: identityId2,
};
const request: ITransferRequest = {
    _type: "TransfersRequest",
    requestId: uuidv4(),
    transfers: [
        transfer,
    ],
};
const signedRequest: IAuthorisedRequest = platformClient.prepareRequest(request, delegateKeyPair, identity1);
platformClient.transferAssets(signedRequest, delegateKeyPair)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Transfer of quantifiable asset using delegate

The method transferAssets transfers assets in the iov42 platform.

import { v4 as uuidv4 } from "uuid";
import { IKeyPairData, PlatformClient, PlatformUtils } from "../iov42/core-sdk";
const keyPair1: IKeyPairData = "<previously generated key pair>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of identity1>";
const identityId1: string = "<existing identityId>";
const identityId2: string = "<existing identityId>";
const accountId1: string = "<existing accountId belonging to identity1>";
const accountId2: string = "<existing accountId belonging to identity2>";
const quantifiableAssetTypeId: string = "<existing assetTpeId>";
const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const platformUtils = new PlatformUtils();
const transfer: ITransferQuantity = {
    assetTypeId: quantifiableAssetTypeId,
    fromAssetId: accountId1,
    quantity: "50",
    toAssetId: accountId2,
};
const request: ITransferRequest = {
    _type: "TransfersRequest",
    requestId: uuidv4(),
    transfers: [
        transfer,
    ],
};
const signedRequest: IAuthorisedRequest = platformClient.prepareRequest(request, delegateKeyPair, identity1);
platformClient.transferAssets(signedRequest, delegateKeyPair)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Transfer of account using delegate

The method transferAssets transfers an account in the iov42 platform.

import { IKeyPairData, PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);

const keyPair1: IKeyPairData = "<previously generated key pair>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of identity1>";
const identityId1: string = "<existing identityId>";
const identityId2: string = "<existing identityId>";
const accountId1: string = "<existing accountId belonging to identity1>";
const quantifiableAssetTypeId: string = "<existing assetTpeId>";
const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const platformUtils = new PlatformUtils();
const transfer: ITransferOwnership = {
    assetId: accountId1,
    assetTypeId: quantifiableAssetTypeId,
    fromIdentityId: identityId1,
    toIdentityId: identityId2,
};
const request: ITransferRequest = {
    _type: "TransfersRequest",
    requestId: uuidv4(),
    transfers: [
        transfer,
    ],
};
const signedRequest: IAuthorisedRequest = platformClient.prepareRequest(request, delegateKeyPair, identity1);
platformClient.transferAssets(signedRequest, delegateKeyPair)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});

Retrieve proof using delegate

The helper method getProof retrieves a proof.

import { v4 as uuidv4 } from "uuid";
import { PlatformClient } from "../iov42/core-sdk";

const rpcUrl = "https://api.sandbox.iov42.dev"; //Url of the iov42 API server
const platformClient = new PlatformClient(rpcUrl);
const requestId: string = "<requestId previously used to interact with iov42 platform>";
const identityId: string = "<existing identityId>";
const delegateKeyPair: IKeyPairData = "<previously generated key pair, for a delegate of identityId>";
platformClient.getProof(requestId, delegateKeyPair, identityId)
.then( (response) => {
    // Check response
})
.catch( (error) => {
    console.error(error);
});
Clone this wiki locally