Infura Integrates with Polygon to Advance Web 3.0

Infura Transactions (ITX) have come to Polygon! Leveraging the Polygon network to support ITX provides applications with a seamless scaling experience. Specifically, ITX allows end users to send transactions without necessarily holding Ether (ETH). ITX ensures that your transactions are safely submitted and not dropped, while abstracting away the complexities with gas management for developers. This results in more transaction safety for infrastructure development and better user flow with less micromanagement.

Infura serves as the backbone for much of Ethereum’s blockchain development, supporting major DeFi outfits like Uniswap and MakerDAO, the world’s most popular decentralized wallet MetaMask, as well as NFT projects including Sorare and Async Art. Some 350,000 developers are using Infura to build applications for Web 3.0.

ITX is automatically enabled for your projects. You can choose to disable it in your Project Settings.

There are three high-level steps you need to take when integrating ITX in your project:

  • On-chain deposit. You generate a private key and deposit some ETH with Infura’s on-chain deposit contract. This action credits your ITX gas tank with the corresponding amount of ETH (after 10 block confirmations). You will use your private key any time you authorize spending from your ITX gas tank.
  • Send a relay request. You send a transaction relay request to your usual Infura endpoint using the ‘relay_sendTransaction’ RPC call. ITX will first check if you have sufficient balance, then lock a portion of your funds and relay the transaction on your behalf to the Ethereum network. 
  • Transaction mined. In an effort to minimize confirmation time and gas paid, ITX will gradually increase the amount of gas you put in and republish the transaction according to a preset schedule. When the transaction does go through, your final transaction fee will be your network fee + ITX fee. You can check your wallet’s new balance of Ethereum tokens by using the ‘relay_getBalance’ RPC call.

Specifically, how do we navigate these three steps? Follow the instructions here:

  1. Set up the ITX provider. All ITX-specific JSON-RPC methods can be accessed via the ‘ethers.js’ built-in ‘InfuraProvider' class, using your dedicated Infura URL.
  1. Create a signer account. You will use the private key for authenticating your ITX transaction requests, and its corresponding public address for identifying your ITX gas tank for your Polygon decentralised applications (DApps).
  1. Check balance. Your signing account needs to have gas tank balance registered with ITX. You can do this by calling the ‘relay_getBalance’ method.
  1. Make a deposit. And finally, we get to the good part: making a deposit into the ITX gas tank. Note that the contract you’re depositing to (itx.eth) is the same address across all Ethereum networks, and your deposit will be registered after 10 block confirmations.
  1. Send a Relay Request. The format of an ITX request is as follows:

A slight note on what’s happening under the hood, ITX generates a unique transaction hash for every relay request made by a smart contract. This consists of the ‘keccak256’ hash of the address, the bytes in the data field, a uint value of gas and the chain id. The relay transaction hash is then signed by using the standard Ethereum message signing process.

You only need to pass in the ‘relayTransactionHash’ into the ‘signRequest’ function.

  1. Example. The code below sends a transaction that calls the ‘echo’ method in a sample contract that is already deployed. ‘relay_sendTransaction’ requires two parameters:
    1. The relay request object (under const tx = {...} )
    2. Your signature

Note: The Ethereum transaction hash is changed every time the fee is bumped according to the schedule and the previous hash is no longer reliable for tracking its status. Because the ITX is completely responsible for sending and broadcasting your transaction, you get back a ‘relayTransactionHash’ instead of an Ethereum transaction hash.

  1. ​​Check your transaction status. There’s a new RPC call ‘relay_getTransactionStatus’ that returns the list of Ethereum Transaction hashes which have been broadcast for the supplied relay ‘TransactionHash’. You can then check client-side whether any of the transaction hashes were mined.

And that’s it! You’ve successfully sent a relay request via the ITX service. From there you can use optimistic rollups, ZK rollups and everything in between. We can’t wait to see how you use the ITX for seamless UX in your Polygon PoS builds!

Keep up with the latest news on Polygon Developers twitter channel, take a deep dive into the available resources or say hi on Discord. Then go build something!

Be a part of our social ecosystem!

Website | Twitter | Ecosystem TwitterDeveloper Twitter | Enterprise Twitter | Studios Twitter | Telegram | Reddit | DiscordInstagram | Facebook | LinkedIn

More from the Polygon Blog
Polygon Announces Polygon Miden - A STARK-Based, Ethereum-Compatible Rollup

TL;DR: We are excited to announce the newest member of the Polygon solution suite - Polygon Miden, an upcoming STARK-based, EVM-compatible rollup. The project is led by Bobbin Threadbare, former Facebook’s core ZK researcher who led the development of Winterfell. Today we are releasing Polygon Miden’s core component - Miden VM, the first open-source STARK-based […]

Read More
Why Web3 Developers Are Choosing Polygon Over Other Solutions 

When it comes to deploying on Ethereum, there is only one place that lets developers easily migrate their projects, offers a broad range of scaling options and has some of the industry’s lowest transaction rates. These are just some of the reasons why the number of teams using Polygon jumped 100-fold in the past year. […]

Read More
EY and Polygon to co-develop Ethereum scaling solutions for enterprises and launch Polygon Nightfall - a privacy-focused Rollup

EY, a global professional services and technology firm, is collaborating with Polygon on building and implementing scaling and enterprise solutions for the Ethereum ecosystem. As part of this collaboration, EY and Polygon will work on Polygon Nightfall, a public, privacy-focused Rollup. In addition to this, EY will offer its other flagship blockchain products on Polygon […]

Read More
What's new in matic.js v3

Matic.js is an open-source javascript library for interacting with the Polygon bridge. It provides APIs for deposits, withdrawals, transfers, etc. The latest version v3 is an all-in-all improvement over its predecessor, which was used in multiple applications. The newest iteration was developed after analyzing and understanding several improvements, feedback, and issues sourced from our community. […]

Read More
Bringing Blockchain to real use cases: Next 2 Billion users

Polygon will be at Blockchance to present findings from its month-long Africa tour about the state of blockchain on the continent.  Polygon Hermez undertook the journey with the support of the Ethereum foundation and found a booming and vibrant blockchain community. On Dec. 4, Polygon’s Enterprise Lead Antoni Martin will present our insights from the […]

Read More
Wintermute Announces $20M Fund To Bootstrap Polygon Dapp Development

The first funded project is Router Protocol, a crosschain messaging protocol that aims to build infrastructure enabling seamless communication between various blockchains. Wintermute, a leading digital asset market maker, and Polygon, an Ethereum scaling platform onboarding millions to the Web3, have today announced a strategic partnership to grow the Polygon ecosystem. Wintermute is launching a […]

Read More