Giter Site home page Giter Site logo

transaction-util-v2's Introduction

Transaction-Util-V2

Transaction-util is a utility for sending transactions to the Polygon network in a robust manner.

Getting started

  • Clone this repository
git clone https://github.com/integrations-Polygon/transaction-util-v2.git
  • Navigate to transaction-util-v2
cd transaction-util-v2
  • Install dependencies
npm install
  • Create .env file
cp .example.env .env
  • Configure environment variables in .env
NETWORK = your_network_name // matic for polygon mainnet
PROJECT_ID = your_provider_project_id
RPC_PROVIDER = your_provider_rpc_url
SIGNER_PRIVATE_KEY = your_private_key
PUBLIC_KEY = your_public_key
EXPLORER_API_KEY = your_explorer_api_key

Usage

Start the Main script by running this command

npx hardhat run ./scripts/startTransaction.js

After that you will be presented with 3 options to choose from:

Option 1: Deploy your smart contract

First, you will be asked to enter the Transaction type you would like to proceed with:

  • Select 1 for legacy
  • Select 2 for EIP-1559 Second, you will have to enter the contract's artifact generated by hardhat, here's an example:
.\artifacts\contracts\Demo.sol\Demo.json    

If the contract has an arguments in its constructor, you wil be asked to enter them.

After that, the script will fetch the gas price from polygon gas station and deploy the contract and wait for 64 block comfirmation. Then a receipt of the Transaction will be saved in a JSON file and in Redis Database.

Finally you can Verify the deployed smart contract by running this command:

npx hardhat verify txReceipt.contractAddress,...arrayOfArgs

Option 2: Call a function of deployed smart contract

First, you will be asked to enter the Transaction type you would like to proceed with:

  • Select 1 for legacy
  • Select 2 for EIP-1559

Second, you will have to enter the address of the already deployed and verified smart contract, here's an example:

0xCCFD7490d9F4a44d3664CDCF5E2721863C507e81   

Then you will be asked to enter the name of the function you want to call, for example:

myFunction   

After that you will have to enter the arguments of the function.

Finally the script will fetch the ABI from the blockchain, initialize all the interfaces, sign the transaction and send it to the network which will result in a receipt that wil be stored in a JSON file and in redis Database after waiting for 64 block confirmation.

Option 3: Send MATIC tokens to a receiving account address

First, you will be asked to enter the Transaction type you would like to proceed with:

  • Select 1 for legacy
  • Select 2 for EIP-1559

Second, you will have to enter the address of the receiver, here's an example:

0x248072cdAd067B95ed80E55a5c7a46Cf50b18e64   

After that you will have to enter the amount of MATIC to be sent. Then you will enter "Y" to confirm that you want to proceed with the transfer or type "N" to exit.

Finally, the script will fetch the gas price from polygon gas station, send the MATIC tokens and waiting for 64 block comfirmation. Then a receipt of the Transaction will be saved in a JSON file and in Redis Database.

transaction-util-v2's People

Contributors

grslammy avatar saifatom avatar

Forkers

grslammy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.