txn.xyz icon indicating copy to clipboard operation
txn.xyz copied to clipboard

Unnecessary ABI lookup

Open ItsNickBarry opened this issue 1 year ago • 5 comments

I'm attempting to run a test transaction on a local Hardhat network that's forking a public network. I suppose this isn't supported, because the UI hangs with the message "Fetching contract ABI...".

This tool would much more useful if this step were avoided, and transactions were encoded using only the query string parameters. Even if there might be security reasons to disallow sending transactions without verified contracts and ABIs, this policy prevents multi-step flows from being tested.

ItsNickBarry avatar May 20 '24 09:05 ItsNickBarry

This is a good suggestion. You're thinking that the ABI itself would also be encoded fully in the URL?

I'm interested @ItsNickBarry if you can make the PR

dawsbot avatar May 23 '24 23:05 dawsbot

One way to do it would be to encode the ABI (also suggested by @startswithaj). Another would be to change the fn field to use a full function signature, like "transfer(address,uint256)" instead of just "transfer". This alone can be used to create a single-function ABI, which is enough to encode and send the transaction.

I prefer the latter option, but it's a bit harder to do in a backwards-compatible way.

ItsNickBarry avatar May 24 '24 07:05 ItsNickBarry

You only need to encode the part of the abi you need for the function call. For a transfer it would just be

?abi="["transfer(address,uint256)"]"

Then process it

const abi = JSON.parse(params.abi)

Otherwise we could add FnSignature as an additional parameter and if thats set ignore fn.

startswithaj avatar May 24 '24 07:05 startswithaj

That's a good spec proposed @startswithaj - If you want to PR this feel free! It should be possible without a breaking change, which is preferred

dawsbot avatar May 29 '24 15:05 dawsbot

Hey @dawsbot I did the PR ser, its here https://github.com/dawsbot/txn.xyz/pull/18

startswithaj avatar Jul 05 '24 07:07 startswithaj