Options
All
  • Public
  • Public/Protected
  • All
Menu

Material class

Hierarchy

Implements

Index

Constructors

constructor

  • new Material(web3: default, _fromAddress: string, factoryContract: any, contractName: BaseContracts, contractAbi: any[]): Material
  • Parameters

    • web3: default
    • _fromAddress: string
    • factoryContract: any
    • contractName: BaseContracts
    • contractAbi: any[]

    Returns Material

Properties

contract

contract: any = null

Protected contractAbi

contractAbi: any[]

Protected contractName

contractName: BaseContracts

Protected factoryContract

factoryContract: any

Protected web3

web3: default

Accessors

fromAddress

  • get fromAddress(): string
  • Returns string

Methods

all

assigedCertificates

  • Get all assigned certificates to a material token

    Parameters

    • materialTokenId: number

      Company address

    Returns Promise<ICertificateInstance[]>

    Array of certificate instances

assignCertificate

  • Assign a certificate to a material

    Parameters

    • options: { certificateCode: number; materialTokenId: number; stake: string }

      Assign Certificate Options

      • certificateCode: number

        The code of the certificate to be assigned

      • materialTokenId: number

        The material token id that will be assigned the certificate to

      • stake: string

        The amount in wei that will be sent as a stake

    Returns Transaction<{ MaterialAssignedCertificate: MaterialAssignedCertificateEvent }>

    Assigned certificate event

cancelCertificate

  • Cancel a certificate from a material

    Parameters

    • options: { certificateCode: number; materialTokenId: number }

      Cancel certificate options

      • certificateCode: number

        The code of the certificate to be canceled

      • materialTokenId: number

        The material token id that the certificate will be canceled

    Returns Transaction<{ MaterialCanceledCertificate: MaterialCanceledCertificateEvent }>

    Canceled certificate event

certificateAssignmentHistory

  • Get certificate assignment history

    Parameters

    • options: { certificateCode?: number; materialTokenId: number }

      Filtering options

      • Optional certificateCode?: number

        The certificate code

      • materialTokenId: number

        The material token id that the certificate was assigned

    Returns Promise<ICertificateAssignmentHistory>

    Certificate history events

countAll

  • Count the number of materials

    Parameters

    Returns Promise<number>

    Number of materials

create

ensureContract

  • ensureContract(): Promise<any>

getBalance

  • getBalance(materialTokenId: number): Promise<number>
  • Get the number of materials the account has

    Parameters

    • materialTokenId: number

      Material token id

    Returns Promise<number>

    The balance of the materials that the "fromAddress" account has

getById

  • getById(materialTokenId: string | number, full?: boolean): Promise<null | IMaterialTokenInfo>
  • Get a material by its token id

    Parameters

    • materialTokenId: string | number

      Material token id

    • full: boolean = true

      Set to true it the resulting object should include recipe details

    Returns Promise<null | IMaterialTokenInfo>

    Material token info

getCertificateInstance

  • Get a certificate instance by a certificate id

    Parameters

    • certificateInstanceId: number

      Certification instance identification number

    Returns Promise<ICertificateInstance>

    A certificate instance

getContractAddress

  • getContractAddress(): Promise<any>

getFromCertificate

  • Get the materials that have the specified certificate assigned

    Parameters

    • certificateCode: number

      Certificate code

    Returns Promise<({ assignEvent: MaterialAssignedCertificateEvent } & ICertificateInstance)[]>

    Materials that have the specified certificate assigned

getMaterialByUuid

  • getMaterialByUuid(materialUuid: number, full?: boolean): Promise<IMaterialInfo>
  • Get the instance of the material by uuid

    Parameters

    • materialUuid: number

      Material uuid

    • full: boolean = false

      Include material batch information

    Returns Promise<IMaterialInfo>

    Material instance

getOwnedMaterialsUuid

  • getOwnedMaterialsUuid(materialTokenId: number): Promise<IMaterialInfo[]>
  • Get owned material instances

    Parameters

    • materialTokenId: number

      Material token id

    Returns Promise<IMaterialInfo[]>

    Uuids

getOwnedMaterialsUuidCodes

  • getOwnedMaterialsUuidCodes(materialTokenId: number): Promise<number[]>
  • get the uuids of the owned material

    Parameters

    • materialTokenId: number

      Material token id

    Returns Promise<number[]>

    Uuids

getPastEvents

  • getPastEvents<T>(eventName: string, filter?: object, includeBlockData?: boolean): Promise<T[]>
  • Type parameters

    • T

    Parameters

    • eventName: string
    • filter: object = {}
    • includeBlockData: boolean = false

    Returns Promise<T[]>

getRawPastEvents

  • getRawPastEvents(eventName: string, filter?: object): Promise<default[]>
  • Parameters

    • eventName: string
    • filter: object = {}

    Returns Promise<default[]>

getTransfers

  • getTransfers(options: { from?: string; materialTokenId?: number; to?: string }): Promise<MaterialTransferEvent[]>
  • Get transfers

    Parameters

    • options: { from?: string; materialTokenId?: number; to?: string }

      Transfer filtering options

      • Optional from?: string

        Transfer sender account

      • Optional materialTokenId?: number

        Transfer material token id

      • Optional to?: string

        Transfer receiver account

    Returns Promise<MaterialTransferEvent[]>

    Transfer events

mint

  • mint(options: { amount?: number; fromBatchId?: number[]; fromBatchMaterialsUuid?: number[][]; materialTokenId: number }): Promise<Transaction<{ MaterialTransfer: MaterialTransferEvent[] }>>
  • Create a new material instance.

    Parameters

    • options: { amount?: number; fromBatchId?: number[]; fromBatchMaterialsUuid?: number[][]; materialTokenId: number }

      Minting options

      • Optional amount?: number

        Amount to mint

      • Optional fromBatchId?: number[]

        Recipe batch id

      • Optional fromBatchMaterialsUuid?: number[][]

        Recipe amount from the corresponding batch id

      • materialTokenId: number

        Material token id to mint

    Returns Promise<Transaction<{ MaterialTransfer: MaterialTransferEvent[] }>>

    Mint event

revokeCertificate

  • Revoke a certificate from a material

    Parameters

    • options: { certificateCode: number; materialTokenId: number }

      Revoke certificate options

      • certificateCode: number

        The code of the certificate to be revoked

      • materialTokenId: number

        The material token id that the certificate will be revoked

    Returns Transaction<{ MaterialRevokedCertificate: MaterialRevokedCertificateEvent }>

    Revoked certificate event

Generated using TypeDoc