addTemplate(contract, sender, data, currency)

Feature

Return raw operation that register a new credential template. Notes: Templates added within one contract cannot have the same template ID. Operator of contract also can execute the function.

Parameters

string contract address,

string sender, object templateData, string currencyID

Return Value

object addTemplateOperation

// [ parameter templateData’s structure ]

{
       templateID: string
       templateName: string
       serviceDate: string | ShortDate
       expirationDate: string | ShortDate
       templateShare: boolean | Bool
       multiAudit: boolean | Bool
       displayName: string
       subjectKey: string
       description: string
       creator: string | Address 
}

example

const contractAddress = "0x41EFb6902ADcb1214a7123b01af66b1D13b89864fca";
const sender = "0x4874C17C354c498cf44D2946612DBe47fBcE7E87fca";
const currencyId = "MCC";
const templateData = {
    templateID: "adksjfxeifjkdjf",
    templateName: "default",
    serviceDate: "2023-10-12",
    expirationDate: "2023-12-31",
    templateShare: true,
    multiAudit: false,
    displayName: "SITcredentials",
    subjectKey: "SITdevcredential",
    description: "proofofdev",
    creator: "0x07469989b2562afF5E5C3B116CD3AA5Ef814e5a1fca",
};

const addTemplateOperation = mitum.credential.addTemplate(contractAddress, sender, templateData, currencyId);
console.log(addTemplateOperation);

// output
Operation {
  id: 'mitum',
  fact: AddTemplateFact {
    hint: Hint { s: 'mitum-credential-add-template-operation-fact' },
    token: Token { s: '2023-10-12 03:38:57.615 +0000 UTC' },
    _hash: <Buffer 75 a7 b3 93 30 f5 f6 0c 56 0d 92 d3 0f 86 01 3e 92 3d 3f 3a f3 82 18 e1 f2 37 a1 d6 7c e5 23 7f>,
    sender: Address {
      s: '0x4874C17C354c498cf44D2946612DBe47fBcE7E87fca',
      type: 'mitum'
    },
    contract: Address {
      s: '0x41EFb6902ADcb1214a7123b01af66b1D13b89864fca',
      type: 'mitum'
    },
    currency: CurrencyID { s: 'MCC' },
    templateID: 'adksjfxeifjkdjf',
    templateName: 'default',
    serviceDate: ShortDate { s: '2023-10-12' },
    expirationDate: ShortDate { s: '2023-12-31' },
    templateShare: Bool { b: true },
    multiAudit: Bool { b: false },
    displayName: 'SITcredentials',
    subjectKey: 'SITdevcredential',
    description: 'proofofdev',
    creator: Address {
      s: '0x07469989b2562afF5E5C3B116CD3AA5Ef814e5a1fca',
      type: 'mitum'
    }
  },
  hint: Hint { s: 'mitum-credential-add-template-operation' },
  _factSigns: [],
  _hash: <Buffer >
}

Last updated