Skip to content

getsafle/transaction-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Safle Transactions Controller

This SDK returns the list of all the transactions done by a particular address. The transactions include both incoming and outgoing transactions. Also provided is a functionality to convert the unreadable EVM transaction data to human readable one.

Installation

To install this SDK,

npm install --save @getsafle/transactions-controller

Initialization

Initialize the constructor,

const safleTransactionsController = require('@getsafle/transactions-controller');

const transactionsController = new safleTransactionsController.TransactionController();

Get incoming transactions


This function returns the list of all the incoming transactions.

const incomingTransactions= await transactionsController.getIncomingTransactions({ address, fromBlock, network, apiKey });
  • address - user wallet public address,
  • fromBlock - Start block number
  • network - ethereum network selected/ chain selected
  • apiKey - etherscan/polygonscan api key(based on the network selected)

Get outgoing transactions


This function returns the list of all the outgoing transactions.

const outgoingTransactions= await transactionsController.getOutgoingTransactions({ address, fromBlock, network, apiKey });
  • address - user wallet public address,
  • fromBlock - Start block number
  • network - ethereum network selected/ chain selected
  • apiKey - etherscan/polygonscan api key(based on the network selected)

Get all transactions


This function returns the list of all the transactions on an address (incoming + outgoing)

const transactions= await transactionsController.getTransactions({ address, fromBlock, network, apiKey });
  • address - user wallet public address,
  • fromBlock - Start block number
  • network - ethereum network selected/ chain selected
  • apiKey - etherscan/polygonscan api key(based on the network selected)

Analyze Transactions


This function accepts an EVM transaction hash and analyzes the transaction to output human readable values.

const result = await transactionsController.analyzeTransaction(transactionHash, rpcUrl, network);
  • transactionHash - The transaction hash for the transaction to be analyzed.
  • rpcUrl - RPC URL of the chain of the transaction hash passed.
  • network - Network to be used to query the safleId. valid inputs - mainnet or testnet

Get Transaction Type


This function returns the type of transaction based on the contract function called.

const transactionType = transactionsController.getTransactionType(functionInput, rpcUrl);
  • functionInput - The function name and the input parameter datatype in string format. eg. transfer(address, uint256).
  • rpcUrl - RPC URL of the chain of the transaction hash passed.

Chains supported

  • ethereum
  • polygon
  • bsc
  • bitcoin
  • avalanche