Class

TransactionManager

TransactionManager(IMyriaClient)

Constructor

# new TransactionManager(IMyriaClient)

Create TransactionManager module

Parameters:
Name Type Description
IMyriaClient IMyriaClient

Interface of Myria Client

View Source modules/TransactionManager.ts, line 8

Example

TransactionManage instance.

// + Approach 1:
  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const moduleFactory = ModuleFactory.getInstance(mClient);
  const transactionManager = moduleFactory.getTransactionManager();

  // + Approach 2:
  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };
  const transactionManager = new TransactionManager(mClient);

Methods

# async bulkTransferERC20Token(transferTokenParams) → {BulkTransferTokenResponse}

Async bulk transfer for ERC-20 Tokens (such as: Myria Tokens, ...)

  • Function only supports ERC20 and Myria Tokens (ERC20) which are registered in Myria System already (i.e. via a deposit).

After bulk transfer was triggered, we can query the status of the batch with the following functions:

  • getTransactionsByGroupRequestIDAndPartnerRefID(groupRequestID: string, partnerRefID: string)
  • getTransactionsByPartnerRefID(partnerRefID: string)
Parameters:
Name Type Description
transferTokenParams TransferTokenParams

Data regarding sender and receivers relevant for the transfer.

View Source modules/TransactionManager.ts, line 1372

Exception: Sender wallet address is required

string

Exception: Bulk transfer should include at least one transfer

string

Exception: Receiver wallet address is required

string

Exception: Only ERC20 Tokens are valid for this type of bulk transfer

string

Exception: Token address is required

string

Http error code 409 - Request-ID/Group-Request-ID already exists

string

Http error code 400 - User wallet (sender or receiver) is not registered

string

Http error code 400 - Vault ID does not have enough funds

string

Http error code 400 - Signature is invalid

string

Transaction data list which have been captured and validated

  • Response structure consist of 3 group of transactions: failed[] / success[] / validationFailed[]
  • All transactions in failed[], relate to failures due to not enough funds or other internal server errors. These transactions cannot be processed.
  • All transactions in validationFailed[], relate to failures due to validation such as L2's signature. These can be retried with amended data.
  • All transactions in success[], indicate that they have been recorded and will be processed by the system.
Example

Sample code on Testnet (Staging) env

    const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
    };

    const MYR_TOKEN_ADDRESS_EXAMPLE = "0xA06116D9...."; // ERC-20 token address - and make sure it is registered in Myria System already
    const RECEIVER_WALLET_ADDRESS = '0xd0D8A467E....'; // Your receiver/users wallet address
    const SENDER_WALLET_ADDRESS = '0x724f337bF0F....'; // Must be the owner of tokens, sender wallet address

    const moduleFactory = ModuleFactory.getInstance(mClient);
    const transactionManager = moduleFactory.getTransactionManager();

    const transferredItems: ItemSignableTransferParams[] = [
      {
        quantizedAmount: String(convertAmountToQuantizedAmount(1)),
        receiverWalletAddress: RECEIVER_WALLET_ADDRESS,
        tokenType: TokenType.ERC20,
        tokenData: {
          tokenAddress: MYR_TOKEN_ADDRESS_EXAMPLE,
        },
      },
      {
        quantizedAmount: String(convertAmountToQuantizedAmount(2)),
        receiverWalletAddress: RECEIVER_WALLET_ADDRESS,
        tokenType: TokenType.ERC20,
        tokenData: {
          tokenAddress: MYR_TOKEN_ADDRESS_EXAMPLE,
        },
      },
      {
        quantizedAmount: String(convertAmountToQuantizedAmount(3)),
        receiverWalletAddress: RECEIVER_WALLET_ADDRESS,
        tokenType: TokenType.ERC20,
        tokenData: {
          tokenAddress: MYR_TOKEN_ADDRESS_EXAMPLE,
        },
      },
    ];

    const transferTokenParams: TransferTokenParams = {
      senderWalletAddress: SENDER_WALLET_ADDRESS,
      groupRequestId: '7257d29c-c96a-4302-8eaf-368a0d62b977', // Can use random UUID to generate groupRequestID
      requestId: '7257d29c-c96a-4302-8eaf-368a0d62b977',  // Can use random UUID to generate requestID
      partnerRefId: 'Project-ID', // Partner project ID
      description: 'Test-Test Bulk Transfer',
      items: transferredItems,
    };

    const transferResult = await transactionManager.bulkTransferERC20Token(
      transferTokenParams,
    );

# async bulkTransferNfts(transferTokenParams) → {BulkTransferTokenResponse}

Asynchronous bulk transfer for NFT Tokens (such as: ERC-721 Tokens, Marketplace NFTs)

  • Function only supports MINTABLE_ERC721 and NFTs which are minted on Myria System

After bulk transfer was triggered, we can query the status of the batch with the following functions:

  • getTransactionsByGroupRequestIDAndPartnerRefID(groupRequestID: string, partnerRefID: string)
  • getTransactionsByPartnerRefID(partnerRefID: string)
Parameters:
Name Type Description
transferTokenParams TransferTokenParams

Data regarding sender and receivers relevant for the transfer.

View Source modules/TransactionManager.ts, line 1292

Exception: Sender wallet address is required

string

Exception: Bulk transfer should include at least one transfer

string

Exception: Receiver wallet address is required

string

Exception: Only MINTABLE_ERC-721 tokens are valid for this type of bulk transfer

string

Exception: Token address is required

string

Error code 409 - Request-ID/Group-Request-ID is already exists

string

Http error code 400 - User wallet (sender or receiver) is not registered

string

Http error code 400 - Vault ID does not have enough funds

string

Http error code 400 - Signature is invalid

string

Transaction data list which have been captured and validated

  • Response structure consist of 3 group of transactions failed[] / success[] / validationFailed[]
  • All transactions in failed[], relate to failures due to not enough funds or other internal server errors. These transactions cannot be processed.
  • All transactions in validationFailed[], relate to failures due to validation such as L2's signature. These can be retried with amended data.
  • All transactions in success[], indicate that they have been recorded and will be processed by the system.
Example

Sample code on Testnet (Staging) env

    const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
    };

    const YOUR_NFT_CONTRACT_ADDRESS = "0xA06116D9...."; 
    const RECEIVER_WALLET_ADDRESS = '0xd0D8A467E....'; // Your receiver/users wallet address
    const SENDER_WALLET_ADDRESS = '0x724f337bF0F....'; // Must be the owner of tokens, sender wallet address

    const moduleFactory = ModuleFactory.getInstance(mClient);
    const transactionManager = moduleFactory.getTransactionManager();

    const transferredItems: ItemSignableTransferParams[] = [
      {
        quantizedAmount: 1, // Should be 1 as always
        receiverWalletAddress: RECEIVER_WALLET_ADDRESS,
        tokenType: TokenType.MINTABLE_ERC721,
        tokenData: {
          tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
          tokenId: '1' // Your minted token ID
        },
      },
      {
        quantizedAmount: 1,
        receiverWalletAddress: RECEIVER_WALLET_ADDRESS,
        tokenType: TokenType.MINTABLE_ERC721,
        tokenData: {
          tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
          tokenId: '2' // Your minted token ID
        },
      },
      {
        quantizedAmount: 1,
        receiverWalletAddress: RECEIVER_WALLET_ADDRESS,
        tokenType: TokenType.MINTABLE_ERC721,
        tokenData: {
          tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
          tokenId: '3' // Your minted token ID
        },
      },
    ];

    const transferTokenParams: TransferTokenParams = {
      senderWalletAddress: SENDER_WALLET_ADDRESS,
      groupRequestId: '7257d29c-c96a-4302-8eaf-368a0d62b977', // Can use random UUID to generate groupRequestID
      requestId: '7257d29c-c96a-4302-8eaf-368a0d62b977',  // Can use random UUID to generate requestID
      partnerRefId: 'Project-ID', // Project-ID on Myria System
      description: 'Test-Test Bulk Transfer',
      items: transferredItems,
    };

    const transferResult = await transactionManager.bulkTransferNfts(
      transferTokenParams,
    );

# async burnERC20Tokens(burnTransferTokenParams) → {BurnTokenResponse}

Asynchronous burn for ERC-20 Tokens or Ethers Tokens (such as: ERC-20, Myria Tokens, Eth)

  • Function only supports ERC-20 standard tokens and Eth on Myria System

After burn transfer was triggered, we can query the status of the batch with the following functions:

  • getTransactionsByGroupRequestIDAndPartnerRefID(groupRequestID: string, partnerRefID: string)
  • getTransactionsByPartnerRefID(partnerRefID: string)
Parameters:
Name Type Description
burnTransferTokenParams BurnTokenParams

Data regarding sender and receivers relevant for the burn.

View Source modules/TransactionManager.ts, line 1630

Exception: Sender wallet address is required

string

Exception: Burn transfer should include at least one transfer

string

Exception: Only ERC-20 or Eth tokens are valided for this burn action

string

Exception: Token address is required

string

Error code 409 - Request-ID/Group-Request-ID is already exists

string

Http error code 400 - User wallet (sender or receiver) is not registered

string

Http error code 400 - Vault ID does not have enough funds

string

Http error code 400 - Signature is invalid

string

Transaction data list which have been captured and validated

  • Response structure consist of 3 group of transactions failed[] / success[] / validationFailed[]
  • All transactions in failed[], relate to failures due to not enough funds or other internal server errors. These transactions cannot be processed.
  • All transactions in validationFailed[], relate to failures due to validation such as L2's signature. These can be retried with amended data.
  • All transactions in success[], indicate that they have been recorded and will be processed by the system.
BurnTokenResponse
Example

Sample code on Testnet (Staging) env

    const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
    };

    const YOUR_TOKEN_CONTRACT_ADDRESS = "0xA06116D9...."; 
    const SENDER_WALLET_ADDRESS = '0x724f337bF0F....'; // Must be the owner of tokens, sender wallet address

    const moduleFactory = ModuleFactory.getInstance(mClient);
    const transactionManager = moduleFactory.getTransactionManager();

    const QUANTUM = 10000000000;
    const burnTransferredItems: ItemSignableBurnParams[] = [
      {
        quantizedAmount: 1, // Should be 1 as always
        tokenType: TokenType.ERC20,
        tokenData: {
          tokenAddress: YOUR_TOKEN_CONTRACT_ADDRESS,
          quantum: QUANTUM
        },
      },
      {
        quantizedAmount: 1,
        tokenType: TokenType.ERC20,
        tokenData: {
          tokenAddress: YOUR_TOKEN_CONTRACT_ADDRESS,
          quantum: QUANTUM
        },
      },
      {
        quantizedAmount: 1,
        tokenType: TokenType.ERC20,
        tokenData: {
          tokenAddress: YOUR_TOKEN_CONTRACT_ADDRESS,
          quantum: QUANTUM
        },
      },
    ];

    const burnTokensParams: BurnTokenParams = {
      senderWalletAddress: SENDER_WALLET_ADDRESS,
      groupRequestId: '7257d29c-c96a-4302-8eaf-368a0d62b977', // Can use random UUID to generate groupRequestID
      requestId: '7257d29c-c96a-4302-8eaf-368a0d62b977',  // Can use random UUID to generate requestID
      partnerRefId: 'Project-ID', // Project-ID on Myria System
      description: 'Test-Test Burn Transfer',
      items: burnTransferredItems,
    };

    const burnTransferResult = await transactionManager.burnERC20Tokens(
      burnTransferTokenParams,
    );

# async burnNfts(burnTokenParams) → {BurnTokenResponse}

Asynchronous burn for NFT Tokens (such as: ERC-721 Tokens, Marketplace NFTs)

  • Function only supports MINTABLE_ERC721 and NFTs which are minted on Myria System

After burn transfer was triggered, we can query the status of the batch with the following functions:

  • getTransactionsByGroupRequestIDAndPartnerRefID(groupRequestID: string, partnerRefID: string)
  • getTransactionsByPartnerRefID(partnerRefID: string)
Parameters:
Name Type Description
burnTokenParams BurnTokenParams

Data regarding sender and receivers relevant for the burn transfer.

View Source modules/TransactionManager.ts, line 1549

Exception: Sender wallet address is required

string

Exception: Burn transfer should include at least one transfer

string

Exception: Only MINTABLE_ERC-721 tokens are valid for this type of bulk transfer

string

Exception: Token address is required

string

Error code 409 - Request-ID/Group-Request-ID is already exists

string

Http error code 400 - User wallet (sender or receiver) is not registered

string

Http error code 400 - Vault ID does not have enough funds

string

Http error code 400 - Signature is invalid

string

Transaction data list which have been captured and validated

  • Response structure consist of 3 group of transactions failed[] / success[] / validationFailed[]
  • All transactions in failed[], relate to failures due to not enough funds or other internal server errors. These transactions cannot be processed.
  • All transactions in validationFailed[], relate to failures due to validation such as L2's signature. These can be retried with amended data.
  • All transactions in success[], indicate that they have been recorded and will be processed by the system.
BurnTokenResponse
Example

Sample code on Testnet (Staging) env

    const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
    };

    const YOUR_NFT_CONTRACT_ADDRESS = "0xA06116D9...."; 
    const SENDER_WALLET_ADDRESS = '0x724f337bF0F....'; // Must be the owner of tokens, sender wallet address

    const moduleFactory = ModuleFactory.getInstance(mClient);
    const transactionManager = moduleFactory.getTransactionManager();

    const burnTransferredItems: ItemSignableBurnTransferParams[] = [
      {
        quantizedAmount: 1, // Should be 1 as always
        tokenType: TokenType.MINTABLE_ERC721,
        tokenData: {
          tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
          tokenId: '1' // Your minted token ID,
          quantum: '1'
        },
      },
      {
        quantizedAmount: 1,
        tokenType: TokenType.MINTABLE_ERC721,
        tokenData: {
          tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
          tokenId: '2' // Your minted token ID,
        },
      },
      {
        quantizedAmount: 1,
        tokenType: TokenType.MINTABLE_ERC721,
        tokenData: {
          tokenAddress: YOUR_NFT_CONTRACT_ADDRESS,
          tokenId: '3' // Your minted token ID
        },
      },
    ];

    const burnTransferTokenParams: BurnTokenParams = {
      senderWalletAddress: SENDER_WALLET_ADDRESS,
      groupRequestId: '7257d29c-c96a-4302-8eaf-368a0d62b977', // Can use random UUID to generate groupRequestID
      requestId: '7257d29c-c96a-4302-8eaf-368a0d62b977',  // Can use random UUID to generate requestID
      partnerRefId: 'Project-ID', // Project-ID on Myria System
      description: 'Test-Test Burn Transfer',
      items: burnTransferredItems,
    };

    const burnTransferResult = await transactionManager.burnNfts(
      burnTransferTokenParams,
    );

# async getSupportedTokens() → {WhitelistTokensResponse}

Get list of tokens supported in Myria

Get details tokens list data which is supported in Myria including TokenHex, TokenQuantum...

View Source modules/TransactionManager.ts, line 1640

Whitelist tokens data

# async getTransactionDetails(transactionId) → {TransactionData}

Get transaction details by transaction ID

Parameters:
Name Type Description
transactionId number

Unique ID of transaction

View Source modules/TransactionManager.ts, line 1189

Exception: Transaction ID should be valided and greater than 0

string

Exception: Get transaction details failed with internal server error

string

Transaction details information (including transactionStatus and createdAt, updatedAt...)

# async getTransactionList(TransactionPagingDetails) → {Array.<TransactionData>}

Get transaction history list by stark key with paging options. This is designed for the purposes of small history reports sorted by latest date.

Paging can be shown one after another (you cannot request for page 3 without first seeing page 1 and 2, for example, as you need details of last transaction of previous page to query for next page).

Parameters:
Name Type Description
TransactionPagingDetails TransactionPagingDetails

Request params to query the list of transactions

View Source modules/TransactionManager.ts, line 1178

List of transaction details

Array.<TransactionData>

# async getTransactionsByGroupRequestIDAndPartnerRefID(groupReqID, partnerRefID, transactionPagingopt) → {Array.<TransactionData>}

Query a list of transactions based on group request ID and Partner Ref ID

Parameters:
Name Type Attributes Description
groupReqID string

The unique group request ID of the transaction batch

partnerRefID string

The unique partner reference ID as Project ID

transactionPaging TransactionPagingDetails <optional>

The pagination params (which included starkKey, limit, createdAt, transactionCategory for query next page)

View Source modules/TransactionManager.ts, line 1404

Exception: Partner Reference ID is required

string

Exception: Group Request ID is required

string

List of transactions data which indicate the status of batch, transaction results, transaction details information (such as transactionID, transactionStatus...)

Array.<TransactionData>
Example

Sample code on Testnet (Staging) env

    const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
    };

    const groupRequestID = "e2fb1ef6-680b-4515-9ca6-0c46bc026ecd";
    const partnerRefId = "10"; // Unique ItemSignableTransferParamsProject ID in Myria System
    const moduleFactory = ModuleFactory.getInstance(mClient);
    const transactionManager = moduleFactory.getTransactionManager();
    const result = await transactionManager.getTransactionsByGroupRequestIDAndPartnerRefID(
      groupRequestID,
      partnerRefId
    );

    console.log('Transaction result -> ', result);

# async getTransactionsByPartnerRefID(partnerRefID) → {Array.<TransactionData>}

Query a list of transactions based on partner reference ID (which should be project ID)

Parameters:
Name Type Description
partnerRefID

The unique partner reference ID (Project ID)

View Source modules/TransactionManager.ts, line 1432

Exception: Partner reference ID is required

string

List of transactions data which indicate the status of batch, transaction results, transaction details information (such as transactionID, transactionStatus...)

Array.<TransactionData>
Example

Sample code on Testnet (Staging) env

    const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
    };

    const partnerRefId = "Project-ID"; // Unique ID of the project on Myria System
    const moduleFactory = ModuleFactory.getInstance(mClient);
    const transactionManager = moduleFactory.getTransactionManager();
    const result = await transactionManager.getTransactionsByPartnerRefID(
      partnerRefId
    );

    console.log('Transaction result -> ', result);

# async transferERC20Token(transferParams) → {TransferResponse}

Single Transfer ERC-20 Token

After transfer was triggered, we can query the status of the transaction with the following functions:

  • getTransactionDetails(transactionId: number) {return TransactionData}
  • getTransactionsByPartnerRefID(partnerRefID: string) {return []TransactionData}
Parameters:
Name Type Description
transferParams TransferERC20Params

Transfer ERC-20 Tokens params (include information for Sender/Receiver)

View Source modules/TransactionManager.ts, line 1450

Exception: Sender vault is not found

string

Exception: Receiver vault is not found

string

Http Status 400 - Sender/Receiver vaults do not exist

string

Http Status 400 - Signature is invalid

string

Http Status 400 - Vault IDs does not have enough funds

string

Transactions data which indicate the status of batch, transaction results, transaction details information (such as transactionID, transactionStatus...)

# async transferERC721Token(transferParams) → {TransferResponse}

Single Transfer ERC-721 (MINTABLE NFT) Token

  • The function is just supported for MINTABLE_ERC721 only

After transfer was triggered, we can query the status of the transaction with the following functions:

  • getTransactionDetails(transactionId: number) {return TransactionData}
  • getTransactionsByPartnerRefID(partnerRefID: string) {return []TransactionData}
Parameters:
Name Type Description
transferParams TransferERC721Params

Transfer ERC-721 token params (including sender and receiver's information)

View Source modules/TransactionManager.ts, line 1207

Exception: Sender vault is not found

string

Exception: Receiver vault is not found

string

Http Status 400 - Sender/Receiver vaults does not exist

string

Http Status 400 - Signature is invalid

string

Http Status 400 - Vault IDs does not have enough funds

string

Transaction details (such as transactionID, transactionStatus...)

# async transferETHToken(transferParams) → {TransferResponse}

Single Transfer ERC-20 Token

After transfer was triggered, we can query the status of the transaction with the following functions:

  • getTransactionDetails(transactionId: number) {return TransactionData}
  • getTransactionsByPartnerRefID(partnerRefID: string) {return []TransactionData}
Parameters:
Name Type Description
transferParams TransferERC20Params

Transfer ERC-20 Tokens params (include information for Sender/Receiver)

View Source modules/TransactionManager.ts, line 1468

Exception: Sender vault is not found

string

Exception: Receiver vault is not found

string

Http Status 400 - Sender/Receiver vaults do not exist

string

Http Status 400 - Signature is invalid

string

Http Status 400 - Vault IDs does not have enough funds

string

Transactions data which indicate the status of batch, transaction results, transaction details information (such as transactionID, transactionStatus...)