Class EvmBlockchainService

java.lang.Object
io.meeds.evm.gamification.service.EvmBlockchainService

@Service public class EvmBlockchainService extends Object
  • Constructor Details

    • EvmBlockchainService

      public EvmBlockchainService()
  • Method Details

    • saveTokenTransactions

      public void saveTokenTransactions(long fromBlock, long toBlock, String contractAddress, String blockchainNetwork, long networkId)
      saves the list of ERC20 Token transfer transactions starting from a block to another
      Parameters:
      fromBlock - Start block
      toBlock - End Block to filter
      contractAddress - The ERC20 token contract address
      blockchainNetwork - The url of used provider
      networkId - Network id
    • getEvmTransactions

      public List<EvmTransaction> getEvmTransactions(long fromBlock, long toBlock, String contractAddress, String blockchainNetwork, org.web3j.abi.datatypes.Event event)
      get the list of ERC20 Token transfer transactions
      Parameters:
      fromBlock - Start block
      toBlock - End Block to filter
      contractAddress - The ERC20 token contract address
      blockchainNetwork - The url of used provider
    • getTokenDetails

      public EvmContract getTokenDetails(String contractAddress, String blockchainNetwork)
      Retrieves the Token details from its contract address
      Parameters:
      contractAddress - the token contract address
      Returns:
      token details
    • detectTokenType

      public String detectTokenType(String blockchainNetwork, String contractAddress)
      Get the Token type from the contract address
      Parameters:
      blockchainNetwork - The url of used provider
      contractAddress - the token contract address
      Returns:
      token type
    • isERC1155

      public boolean isERC1155(String blockchainNetwork, String contractAddress)
      Check if the Token is an ERC-1155 or not
      Parameters:
      blockchainNetwork - The url of used provider
      contractAddress - the token contract address
      Returns:
      true if an ERC-1155
    • isERC721

      public boolean isERC721(String blockchainNetwork, String contractAddress)
      Check if the Token is an ERC-721 or not
      Parameters:
      blockchainNetwork - The url of used provider
      contractAddress - the token contract address
      Returns:
      true if an ERC-721
    • getLastBlock

      public long getLastBlock(String blockchainNetwork)
      Returns:
      last block number
    • balanceOf

      public BigInteger balanceOf(String contractAddress, String blockchainNetwork, Map<String,String> functionParams)
      Parameters:
      contractAddress - Address to get its token balance
      blockchainNetwork - Used provider url
      functionParams - Function parameters
      Returns:
      BigInteger representing the balance of address of token which is retrieved from the used blockchain.
    • isBalanceEnough

      public boolean isBalanceEnough(String contractAddress, String blockchainNetwork, String walletAddress, io.meeds.gamification.model.RuleDTO rule, List<EvmTransaction> transactions)
    • getTransactionTransferEvents

      public List<EvmBlockchainService.TransferEventResponse> getTransactionTransferEvents(org.web3j.protocol.core.methods.response.TransactionReceipt transactionReceipt, String contractAddress, org.web3j.abi.datatypes.Event event)
    • extractEventParametersWithLog

      protected List<EvmBlockchainService.EventValuesWithLog> extractEventParametersWithLog(org.web3j.abi.datatypes.Event event, org.web3j.protocol.core.methods.response.TransactionReceipt transactionReceipt)
    • extractEventParametersWithLog

      protected EvmBlockchainService.EventValuesWithLog extractEventParametersWithLog(org.web3j.abi.datatypes.Event event, org.web3j.protocol.core.methods.response.Log log)
    • staticExtractEventParametersWithLog

      protected static EvmBlockchainService.EventValuesWithLog staticExtractEventParametersWithLog(org.web3j.abi.datatypes.Event event, org.web3j.protocol.core.methods.response.Log log)