ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

authorizationList structure compatibility with eth_estimateGas

Open EthanBlockson opened this issue 6 months ago • 1 comments

Describe the Feature

Make it easier to pass authorizationList directly to RPC call without additional preparation.

Code Example

Heres example how authorization object look like after wallet.authorize().

{
  address: '0x186dDEA073ebceCBF845D5AEabB742902316C777',
  nonce: 6n,
  chainId: 11155111n,
  yParity: 1,
  r: '0x686dba08151c21c076967366fadfda3a281c56b0adf8a310e4a367bd75583e97',
  s: '0x48bf566e32cd6ff375e8667f893eb1676cfe52d94633064bb8c55751e17a8063'
}

This object can't be passed directly as authorizationList to call provider.send('eth_estimateGas') leading to an serialisation error:

TypeError: Do not know how to serialize a BigInt

Maybe theres a solutions to serialize it automatically on ethers side. Just an idea.

e.g.

  const modifiedAuthorization = {
    address: authorization.address,
    nonce: toQuantity(authorization.nonce),
    chainId: toQuantity(authorization.chainId),
    r: authorization.signature.r,
    s: authorization.signature.s,
    yParity: toQuantity(authorization.signature.yParity),
  };

EthanBlockson avatar Jun 16 '25 12:06 EthanBlockson

There is a method on the JsonRpcProvider class, `getRpcTransaction' which will normalize all the values to be JSON-RPC compatible and take care of a lot of other idiosyncrasies for you. :)

ricmoo avatar Jun 20 '25 22:06 ricmoo