Class

FabricERC20ClientRepository

FabricERC20ClientRepository()

Repository for interacting with ERC20 contracts on a Hyperledger Fabric network. Extends the base FabricClientRepository class and utilizes the ClientSerializer for data serialization.

Constructor

# new FabricERC20ClientRepository()

View Source client/erc20/FabricERC20ClientRepository.ts, line 12

Classes

FabricERC20ClientRepository

Methods

# async allowance(owner, spender) → {Promise.<number>}

This function interacts with the blockchain network to fetch the allowance of ERC20 tokens that the specified owner has approved for a spender.

This function interacts with the blockchain network to fetch the allowance of ERC20 tokens that the specified owner has approved for a spender. It calls the "Allowance" transaction on the smart contract with the owner's address and the spender's address as parameters. The returned data is then decoded and converted to a number.

Parameters:
Name Type Description
owner

The address of the ERC20 token owner.

spender

The address of the spender.

View Source client/erc20/FabricERC20ClientRepository.ts, line 513

If the transaction fails or the decoding process fails.

Error

A promise that resolves with the allowance of ERC20 tokens that the specified owner has approved for the spender.

Promise.<number>

# async approve(spender, value) → {Promise.<boolean>}

Approves a specified amount of ERC20 tokens to be spent by a specified spender.

Approves a specified amount of ERC20 tokens to be spent by a specified spender.

This function interacts with the blockchain network to approve a specified amount of ERC20 tokens to be spent by a specified spender. It calls the "Approve" transaction on the smart contract with the spender's address and the approval amount as parameters. The returned data is then decoded and checked to determine if the approval was successful.

Parameters:
Name Type Description
spender

The address of the spender.

value

The amount of ERC20 tokens to approve for the spender.

View Source client/erc20/FabricERC20ClientRepository.ts, line 495

If the transaction fails or the decoding process fails.

Error

A promise that resolves with true if the approval was successful, and false otherwise.

Promise.<boolean>

# async balanceOf(owner) → {Promise.<number>}

This function interacts with the blockchain network to fetch the balance of the ERC20 token for a given owner.

This function interacts with the blockchain network to fetch the balance of the ERC20 token for a given owner. It calls the "BalanceOf" transaction on the smart contract with the provided owner's address as a parameter. The returned data is then decoded and converted to a number.

Parameters:
Name Type Description
owner

The address of the ERC20 token owner.

View Source client/erc20/FabricERC20ClientRepository.ts, line 440

If the transaction fails or the decoding process fails.

Error

A promise that resolves with the balance of the ERC20 token for the specified owner.

Promise.<number>

# async burn(amount) → {Promise.<void>}

Burns a specified amount of ERC20 tokens from the minter's account.

Burns a specified amount of ERC20 tokens from the minter's account.

This function interacts with the blockchain network to burn a specified amount of ERC20 tokens. It calls the "Burn" transaction on the smart contract with the burning amount as a parameter. The function does not return any value, but it decreases the minter's number of tokens.

Parameters:
Name Type Description
amount

The amount of ERC20 tokens to burn.

View Source client/erc20/FabricERC20ClientRepository.ts, line 576

If the transaction fails.

Error

A promise that resolves when the burning process is completed.

Promise.<void>

# async burnFrom(account, amount) → {Promise.<void>}

Burns a specified amount of ERC20 tokens from a specified account.

Burns a specified amount of ERC20 tokens from a specified account.

This function interacts with the blockchain network to burn a specified amount of ERC20 tokens from a given account. It calls the "BurnFrom" transaction on the smart contract with the account's address and the burning amount as parameters. The function does not return any value, but it decreases the specified account's number of tokens.

Parameters:
Name Type Description
account

The address of the account from which to burn the ERC20 tokens.

amount

The amount of ERC20 tokens to burn.

View Source client/erc20/FabricERC20ClientRepository.ts, line 593

If the transaction fails.

Error

A promise that resolves when the burning process is completed.

Promise.<void>

# async checkInitialized() → {Promise.<void>}

Checks if the ERC20 contract has been initialized.

Checks if the ERC20 contract has been initialized.

This function interacts with the blockchain network to verify if the ERC20 contract has been initialized. It calls the "CheckInitialized" transaction on the smart contract, which does not require any parameters.

View Source client/erc20/FabricERC20ClientRepository.ts, line 543

If the transaction fails.

Error

A promise that resolves when the initialization check is completed.

Promise.<void>

# async clientAccountBalance() → {Promise.<number>}

Retrieves the balance of ERC20 tokens associated with the client's account.

Retrieves the balance of ERC20 tokens associated with the client's account.

This function interacts with the blockchain network to fetch the balance of ERC20 tokens associated with the client's account. It calls the "ClientAccountBalance" transaction on the smart contract, which does not require any parameters. The returned data is then decoded and converted to a number.

View Source client/erc20/FabricERC20ClientRepository.ts, line 607

If the transaction fails or the decoding process fails.

Error

A promise that resolves with the balance of ERC20 tokens associated with the client's account.

Promise.<number>

# async clientAccountID() → {Promise.<string>}

Retrieves the client's account ID from the blockchain network.

Retrieves the client's account ID from the blockchain network.

This function interacts with the blockchain network to fetch the client's account ID. It calls the "ClientAccountID" transaction on the smart contract, which does not require any parameters. The returned data is then decoded and returned as a string.

View Source client/erc20/FabricERC20ClientRepository.ts, line 621

If the transaction fails or the decoding process fails.

Error

A promise that resolves with the client's account ID.

Promise.<string>

# async decimals() → {Promise.<number>}

Retrieves the number of decimal places for the ERC20 token.

Retrieves the number of decimal places for the ERC20 token.

This function interacts with the blockchain network to fetch the number of decimal places for the ERC20 token. It calls the "Decimals" transaction on the smart contract and decodes the returned data.

View Source client/erc20/FabricERC20ClientRepository.ts, line 410

If the transaction fails or the decoding process fails.

Error

A promise that resolves with the number of decimal places for the ERC20 token.

Promise.<number>

# decode(data)

Decodes a Uint8Array into a string using the TextDecoder.

Decodes a Uint8Array into a string using the TextDecoder.

Parameters:
Name Type Description
data

The Uint8Array to decode.

View Source client/erc20/FabricERC20ClientRepository.ts, line 370

The decoded string.

# async initialize(token) → {Promise.<boolean>}

This function interacts with the blockchain network to initialize the ERC20 contract with the given token information.

This function interacts with the blockchain network to initialize the ERC20 contract with the given token information. It calls the "Initialize" transaction on the smart contract with the serialized token data as a parameter. The returned data is then decoded and checked to determine if the initialization was successful.

Parameters:
Name Type Description
token

The ERC20 token information to initialize the contract with.

View Source client/erc20/FabricERC20ClientRepository.ts, line 530

If the transaction fails or the decoding process fails.

Error

A promise that resolves with true if the initialization was successful, and false otherwise.

Promise.<boolean>

# async mint(amount) → {Promise.<void>}

This function interacts with the blockchain network to mint a specified amount of ERC20 tokens.

This function interacts with the blockchain network to mint a specified amount of ERC20 tokens. It calls the "Mint" transaction on the smart contract with the minting amount as a parameter. The function does not return any value, but it updates the minter's number of tokens.

Parameters:
Name Type Description
amount

The amount of ERC20 tokens to mint.

View Source client/erc20/FabricERC20ClientRepository.ts, line 560

If the transaction fails.

Error

A promise that resolves when the minting process is completed.

Promise.<void>

# async symbol() → {Promise.<string>}

Retrieves the symbol of the ERC20 token.

Retrieves the symbol of the ERC20 token.

This function interacts with the blockchain network to fetch the symbol of the ERC20 token. It calls the "Symbol" transaction on the smart contract and decodes the returned data.

View Source client/erc20/FabricERC20ClientRepository.ts, line 397

If the transaction fails or the decoding process fails.

Error

A promise that resolves with the symbol of the ERC20 token.

Promise.<string>

# async tokenName() → {Promise.<string>}

This function interacts with the blockchain network to fetch the name of the ERC20 token.

This function interacts with the blockchain network to fetch the name of the ERC20 token. It calls the "TokenName" transaction on the smart contract and decodes the returned data.

View Source client/erc20/FabricERC20ClientRepository.ts, line 384

If the transaction fails or the decoding process fails.

Error

A promise that resolves with the name of the ERC20 token.

Promise.<string>

# async totalSupply() → {Promise.<number>}

Retrieves the total supply of the ERC20 token.

Retrieves the total supply of the ERC20 token.

This function interacts with the blockchain network to fetch the total supply of the ERC20 token. It calls the "TotalSupply" transaction on the smart contract and decodes the returned data.

View Source client/erc20/FabricERC20ClientRepository.ts, line 423

If the transaction fails or the decoding process fails.

Error

A promise that resolves with the total supply of the ERC20 token.

Promise.<number>

# async transfer(to, value) → {Promise.<boolean>}

This function interacts with the blockchain network to transfer a specified amount of ERC20 tokens to a recipient.

This function interacts with the blockchain network to transfer a specified amount of ERC20 tokens to a recipient. It calls the "Transfer" transaction on the smart contract with the recipient's address and the transfer amount as parameters. The returned data is then decoded and checked to determine if the transfer was successful.

Parameters:
Name Type Description
to

The address of the recipient.

value

The amount of ERC20 tokens to transfer.

View Source client/erc20/FabricERC20ClientRepository.ts, line 458

If the transaction fails or the decoding process fails.

Error

A promise that resolves with true if the transfer was successful, and false otherwise.

Promise.<boolean>

# async transferFrom(from, to, value) → {Promise.<boolean>}

This function interacts with the blockchain network to transfer a specified amount of ERC20 tokens from one account to another.

This function interacts with the blockchain network to transfer a specified amount of ERC20 tokens from one account to another. For this transfer to work the spender ( account that will trigger this function ) need to have the value approved as an allowance by the sender. It calls the "TransferFrom" transaction on the smart contract with the sender's address, recipient's address, and the transfer amount as parameters. The returned data is then decoded and checked to determine if the transfer was successful.

Parameters:
Name Type Description
from

The address of the sender.

to

The address of the recipient.

value

The amount of ERC20 tokens to transfer.

View Source client/erc20/FabricERC20ClientRepository.ts, line 478

If the transaction fails or the decoding process fails.

Error

A promise that resolves with true if the transfer was successful, and false otherwise.

Promise.<boolean>

# async updateObservers(table, event, id, …args) → {Promise.<void>}

Updates all registered observers with information about a database event.

Notifies all observers of an event.

Parameters:
Name Type Attributes Description
table string

The table name where the event occurred.

event OperationKeys | BulkCrudOperationKeys | string

The type of event that occurred.

id EventIds

The ID or IDs of the affected records.

args Array.<any> <repeatable>

Additional arguments.

View Source client/erc20/FabricERC20ClientRepository.ts, line 362

If the observer handler is not initialized.

InternalError

A promise that resolves when all observers have been notified.

Promise.<void>