Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVM: standard (?) field input not allowed in eth transaction #2048

Closed
kuegi opened this issue Jun 11, 2023 · 10 comments · Fixed by #2051
Closed

EVM: standard (?) field input not allowed in eth transaction #2048

kuegi opened this issue Jun 11, 2023 · 10 comments · Fixed by #2051
Labels

Comments

@kuegi
Copy link
Contributor

kuegi commented Jun 11, 2023

even a simple eth_call fails with
unknown field input, expected one of from, to, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gas, value, data, nonce, accessList, type
if the input field is provided. But this seems to be standard in eth. The generated tx by web3.js contains data and input with the same content.

@kuegi kuegi added the bug label Jun 11, 2023
@shohamc1
Copy link
Contributor

Hey, which RPC are you referring to here?

I just checked the Ethereum docs (here and here), and none of them have an input field for eth_call.

@kuegi
Copy link
Contributor Author

kuegi commented Jun 12, 2023

Problem happens both with eth_call and eth_sendTransaction. Interessting that its not in the ETH docs. Then the question is why web3.js adds it to the call (with same value as data ) https://github.com/web3/web3.js/blob/f8a2533c2b09ce0a62f8414f2f6eed83ab78ca1f/packages/web3-types/src/eth_types.ts#L66

I will try to investigate.

@shohamc1
Copy link
Contributor

May I know what you are trying to achieve with your script, and maybe share your code if you can.

eth_sendTransaction does not have an input field as well.

@kuegi
Copy link
Contributor Author

kuegi commented Jun 12, 2023

I wanted to write a bot to interact with a SC deployed to DMC. SC is deployed and interaction via Remix works smoothly. but via web3 I get the mentioned error. will try to debug why web3 is adding the input.

can't add .ts files. the code is

import { Contract, Web3 } from 'web3'
const contractABI = [ /* pretty long, so removed here*/ ] as const
const dmcAddress= '0x67488912788Bf6C634909f4411047aE0136C801A'

async function interact(): Promise<void> {
  const w3: Web3 = new Web3('https://testnet-dmc.mydefichain.com:20551')
  const contract = new Contract(contractABI,dmcAddress , w3)

  const currentBlock = await w3.eth.getBlockNumber()

  const lastInputBlock: bigint = await contract.methods.lastInputBlock().call()
  const waitTime: bigint = await contract.methods.WAIT_TIME_BLOCKS().call()
  const lastSender = await contract.methods.lastInput().call()
  console.log('got data: ' + currentBlock + ' ' + lastSender + ' ' + lastInputBlock + ' ' + waitTime)
}

interact()

@shohamc1
Copy link
Contributor

This test is using web3.py and functions without error.

On web3.js I believe the code for declaring a new contract should look like

const web3 = new Web3(process.env.PROVIDER);
const contract = new web3.eth.Contract(ABI, contractAddress);

@kuegi
Copy link
Contributor Author

kuegi commented Jun 12, 2023

Its explicitly being set by web3.js here https://github.com/web3/web3.js/blob/f8a2533c2b09ce0a62f8414f2f6eed83ab78ca1f/packages/web3-eth/src/utils/format_transaction.ts#L43-L56

they assert that data and input is same, and make sure that both are set.

(and same result if I create it with your code)

@kuegi
Copy link
Contributor Author

kuegi commented Jun 12, 2023

And here, input is part of the rpc-api https://ethereum.github.io/execution-apis/api-documentation/ weirdly enough, there it doesn't include data
image

maybe this is an old definition and it was input in the beginning and got changed to data ? But since this spec is linked from the docu that you provided up there, it seems that ethereum itself is not consistent if it should be data or input...

@Meiswinkel1991
Copy link

I often use the docs from alchemy for such cases. In the following link you will find everything about eth_call.

https://docs.alchemy.com/reference/sdk-call

I personally have never heard of "input". Until now I have always worked with "data".

@shohamc1
Copy link
Contributor

@kuegi the linked PR should allow you to use eth_call from web3.js.

Tested with the following code

import Web3 from "web3"

const web3 = new Web3(process.env.PROVIDER);
const contract = new web3.eth.Contract(ABI, contractAddress);

console.log(await contract.methods.retrieve().call())

@kuegi
Copy link
Contributor Author

kuegi commented Jun 12, 2023

@shohamc1 can confirm that eth_call works now, but interacting via transaction still fails on existing input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants