@minespider/core-bundles
Version:
A high-level SDK for Minespider Core. It abstract the low-level features from the core SDK for a more high-level usage such as DAPPs. Some of the features are 1:1 with the SDK some others abstract some low-level interactions or multiple actions
42 lines (38 loc) • 1.2 kB
text/typescript
import { MinespiderFacade } from "../../src/MinespiderBundle/Business/MinespiderFacade";
import { CertificateFile } from "@minespider/core-sdk";
export const createCertificate = async (
facade: MinespiderFacade,
amount: number
) => {
const publicFileList = [
new CertificateFile(
Buffer.from("public file " + Math.random()),
"public.txt",
{
type: "text/plain"
}
)
];
const privateFileList = [
new CertificateFile(
Buffer.from("private file " + Math.random()),
"private.txt",
{
type: "text/plain"
}
)
];
const certificateEnvelopeAddress = await facade.createCertification({
owner: await facade.getCurrentAccountAddress(),
certificateAmount: amount,
certificateRawAmount: amount,
certificateGrade: 100,
certificateUnit: "kg",
certificateProducer: await facade.getCurrentAccountAddress(),
materialTaxonomyUuid: "0x80A3b76017A49E0F75E041086b19c573D89aB990",
materialTypeUuid: "0xF4cE2A980cdc7C7F84aAB07636a51AF008c8465C",
publicFiles: publicFileList,
privateFiles: privateFileList
});
return await facade.downloadCertificateEnvelope(certificateEnvelopeAddress);
};