Using the EIP-1193 Provider
portal.provider is compliant with the EIP-1193 specification and can be used with libraries like ethers.js and web3.js. This guide will walk you through using portal.provider with ethers.js.
Last updated
Was this helpful?
portal.provider is compliant with the EIP-1193 specification and can be used with libraries like ethers.js and web3.js. This guide will walk you through using portal.provider with ethers.js.
Last updated
Was this helpful?
Here's a code snippet that sends a transaction with ethers.js
backed by portal.provider
.
Let's break it down.
First, portal.updateChain
is used to bind portal.provider
to a specific EVM chain. It takes the chain's reference, for example 11155111
for Sepolia, as argument.
portal.provider
is then supplied to . The returned object is an and to the chain. To be able to send a transaction we need a which ethersProvider.getSigner
returns.
The next bit of code is ethers.js
specific and uses ethersSigner.sendTransaction
to send 0.001 ETH to the address specified. The code also waits for the transaction to be mined.
That's all! We've successfully used portal.provider
and ethers.js
to send a transaction!