argentlabs / web3.swift

Ethereum Swift API with support for smart contracts, ENS & ERC20
MIT License
668 stars 168 forks source link

Getting execution revert every time I try create an eth_Transaction #373

Open mrktrace opened 2 months ago

mrktrace commented 2 months ago

Good morning,

I'm currently facing an issue while trying to create an EthereumTransaction and seems to have a wrong format.

The context is, I'm connected by a wallet connect socket to UniSwap for an exchange transaction.

Then when I receive the body of the request the format is as follows:

  {
  "data": "0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000667d3d6b00000000000000000000000000000000000000000000000000000000000000040b000604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000000024fe114a600000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0d500b1d8e8ef31e21c99d1db9a6444d3adf1270000064b7b31a6bc18e48888545ce79e83e06003be709300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000b7b31a6bc18e48888545ce79e83e06003be7093000000000000000000000000023b5aa437cfdaf03235d78961e032dba549dfc0600000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000060000000000000000000000000b7b31a6bc18e48888545ce79e83e06003be709300000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000024fe114a6",
  "to": "0xec7be89e9d109e7e3fec59c222cf297125fefda2", 
  "from": "0xdef9078ed59871afa59c14e9cbdf95a013192950", 
  "gas": "0x3c183", 
  "value": "0x2540be400"
  }

And with it I try to create the following transaction

let gasPrice = try await client.eth_gasPrice()

EthereumTransaction(
    from: EthereumAddress(body.from),
    to: EthereumAddress(body.to),
    value: BigUInt(hex: body.value),
    data: Data.fromHex(body.data)!,
    nonce: nil,
    gasPrice: gasPrice,
    gasLimit: nil,
    chainId: 137
)

And then I create an EthereumHttpClient for Polygon, using https://polygon-rpc.com as rpcURL

Unfortunately if I try to call for

client.eth_estimateGas(transaction)

or

try account.sign(transaction: transaction)

In both cases I will receive an executionError code 3, execution reverted.

Could you please provide some example on how to proceed?

Thank you very much

PD: Before you ask, yes the account has enough funds to perform the action.

mrktrace commented 2 months ago

Just another hint.

If I would call for

try account.sign(transaction: transaction)

I receive an emptyRawTransaction error