Questions tagged [ethers.js]

A lightweight JavaScript library which can be used as an alternative to Web3.js to build your JavaScript front-end and interact with the Ethereum blockchain.

The ethers.js library aims to be a complete and compact library for interacting with the Ethereum Blockchain and its ecosystem. It was originally designed for use with ethers.io and has since expanded into a much more general-purpose library.

Features:

  • Keep your private keys in your client, safe and sound
  • Import and export JSON wallets (Geth, Parity and crowdsale)
  • Import and export BIP 39 mnemonic phrases (12 word backup phrases) and HD Wallets (English, French, Italian, Japanese, Korean, Simplified Chinese, Spanish, Traditional Chinese)
  • Meta-classes create JavaScript objects from any contract ABI, including ABIv2 and Human-Readable ABI
  • Connect to Ethereum nodes over JSON-RPC, INFURA, Etherscan, or MetaMask
  • ENS names are first-class citizens; they can be used anywhere an Ethereum addresses can be used
  • Tiny (~84kb compressed; 270kb uncompressed)
  • Complete functionality for all your Ethereum needs
  • Extensive documentation
  • Large collection of test cases which are maintained and added to
  • Fully TypeScript ready, with definition files and full TypeScript source
  • MIT License (including ALL dependencies); completely open source to do with as you please
1641 questions
14
votes
2 answers

Sample code in ethers.js to send raw transaction and to sign transaction

Is there any sample code in ethers.js to send raw transaction and to sign transactions?
Louis
  • 1,155
  • 5
  • 17
  • 29
13
votes
2 answers

How to call a contract function/method using ethersjs

I for the life of me cannot figure out how to simply call a function from a smart contract when a button is pressed on the front end. I have been reading over the docs and watching countless tutorials over the past week and still cannot figure out…
Jabari Brown
  • 137
  • 1
  • 1
  • 5
13
votes
1 answer

How to decode input data in ethersjs

I am using ethersjs. I use the following code to get data of transaction var init = function () { var wss = new ethers.providers.WebSocketProvider(url); wss.getTransaction(tx).then(function (transaction) { wss.on("pending", (tx) =>…
Jay Williams
  • 159
  • 1
  • 1
  • 8
10
votes
2 answers

is there a way to get the result of web3's encodeFunctionCall with ethers?

I'm using web3 to get the RLP encoded data for a function call like so const safeTransferFrom: any = tokenERC1155Abi.find((f) => f.name === 'safeTransferFrom'); const params: Array = [identity, minterAddr, 1, amount,…
Micha Roon
  • 2,203
  • 21
  • 36
9
votes
2 answers

How can I know a hash mined and confirmed by ethers.js

In ethers.js is there any way I can check whether a hash is mined and confirmed so that I know it is not reverted and valid?
Louis
  • 1,155
  • 5
  • 17
  • 29
8
votes
2 answers

How do I manually encode and send transaction data?

Say I want my contract (in assembly) to be more gas efficient and can handle deserialization of a more efficient msg.data myself than the standard ABI.. I am willing to spend time on the client in order for the contract processing to be more gas…
nxstock-trader
  • 271
  • 1
  • 3
  • 8
7
votes
2 answers

How to create an empty bytes or bytes32 in ethersjs?

I have a function that takes a bytes in solidity, and I want to pass it an empty bytes string without doing "0x000...", can I do this in ethersjs?
Patrick Collins
  • 11,186
  • 5
  • 44
  • 97
6
votes
2 answers

How can ethers.js using infura as provider?

How can I use Infura as the provider for ethers.js? Whether I can use sendtransaction api in ethers.js if I use infura as the provider?
Louis
  • 1,155
  • 5
  • 17
  • 29
5
votes
1 answer

Call function in contract deployed in etherjs

Here is the code I used to call setValue and getValue in contract Hello.sol deployed with etherjs 5.0: import { ContractFactory, ethers } from "ethers"; let contract_at_address = new ethers.Contract(contract.address, abi, signer);…
user938363
  • 669
  • 1
  • 6
  • 23
4
votes
1 answer

How can I set the gas price using ethers.js on uniswap

I'm trying to create a transaction but I can't figure out how to set the gas price. Here's my current code, but according to https://uniswap.org/docs/v2/smart-contracts/router02/#swapexacttokensfortokens there is nowhere to define gas price if I'd…
HJo
  • 193
  • 2
  • 6
3
votes
1 answer

Can jsonRpcProvider.getSigner() take any address as an argument?

I am using the ethersjs when I connect to web3. And I have a question about the getSigner() method below. https://docs.ethers.io/v5/api/providers/jsonrpc-provider/#JsonRpcProvider-getSigner Does this mean that if I pass someone else's ethereum…
user76333
  • 167
  • 2
  • 15
3
votes
1 answer

How to assign networkish for provider?

Here is the doc about provider in ethers 5.x document: new ethers.providers.JsonRpcProvider( [ urlOrConnectionInfo [ , networkish ] ] ) Connect to a JSON-RPC HTTP API using the URL or ConnectionInfo urlOrConnectionInfo connected to the networkish…
user938363
  • 669
  • 1
  • 6
  • 23
3
votes
1 answer

Get number of all the past events using ethers v5

I am writing an integration test and I need to get the number of all the past events using ether.js. The issue I am having is that it seems like I receive only 1 event even though there should be 4 in total. Here is the code I use: const provider…
Jan Beneš
  • 569
  • 1
  • 7
  • 14
3
votes
1 answer

My Wallet does not have signTypedData as a function

I am using "ethers": "^5.6.2" and this is running through a browser. I am also using "eth-permit": "^0.2.1". As to the documentation for eth-permit, I can send a Wallet object as the provider for signDaiPermit(provider, token|Domain,…
Jake
  • 51
  • 3
3
votes
3 answers

Get the real error of transaction failed

I have already searched the web and on this site there is this question but with no solution. I'm using ethers.js on browser with MetaMask. I need to know the real reason for the failure, not just whether it fails or not, as shown here on…
user2342558
  • 240
  • 1
  • 4
  • 11
1
2 3 4 5 6 7