-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
Contract Function Execution Error Due To Different Contract Function Param Name #2703
Comments
I can't reproduce this. Can you provide a minimal reproduction, or try break mine? |
Hello @Metaxona. Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository. Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster. Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue. |
Here's a reproduction repo without the private ley so you have to provide yours https://github.com/Metaxona/viem-issue-2703 this one also has the address of the contract being used which is causing an error. the contract is verified on sepolia etherscan also i forgot to mention i am simulating the transactions first before sending them so that might be the problem |
The To get this to work, you will need to make |
hmmm, i did not notice that. so i got this code from usdt deployed on ethereum mainnet which is weird too since they are linking the implementations on the code to the eip 20 docs and another weird thing is using
viem-issue-2703 git:(main) cast sig "function approve(address _spender, uint256 _value) returns (boolean success)"
0x095ea7b3
viem-issue-2703 git:(main) cast sig "function approve(address _spender, uint256 _value)"
0x095ea7b3
viem-issue-2703 git:(main) cast sig "function approve(address spender, uint256 value)"
0x095ea7b3
viem-issue-2703 git:(main) cast sig "function approve(address spender, uint256 value) returns (boolean success)"
0x095ea7b3
viem-issue-2703 git:(main) cast sig "function approve(address spender, uint256 value) returns (boolean _success)"
0x095ea7b3 so with this, that call should work since they all generate the same function signature with or without the return output |
That is correct. Selectors are computed from the keccak256 hash of a contract signature, and a signature only contains the method name + parameters. The call is not working because Viem is expecting a return value ( |
hmmm that checks out, cause if viem is not expecting anything to return it would still work though there's a problem with this making the built-in erc20Abi from viem unable to be used on all erc20 tokens that follows the standard or atleast most of it like in the case of USDT on ethereum mainnet so i guess to solve this problem without relying on viem to fix it on the source side of the code would be to set the exact abi used by the contract for this kind of situations then and just put it in an object like also yeah the error also says that it returned not data |
This issue has been locked since it has been closed for more than 14 days. If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread. |
Check existing issues
Viem Version
2.19.7
Current Behavior
i am having a problem using erc20Abi specifically approve since in the erc20Abi the approve uses
while the contract i am trying it on uses
which made it impossible for me to call the function and will likely happen on every erc20 tokens that uses a different param name
and throws an error like this
Expected Behavior
the call should use the signature without the param name like this
which from what I know, what evm uses when calculating function signatures instead of including the param names (correct me if i am wrong on this one)
by ignoring the param names, it won't affect the contract interactions due to having a conflict in param names from the standard abi and the one being implemented on the contract
there's also the issue about that from both the eip site and the one openzeppelin use being different
EIP-20
Openzeppelin
here you will see that the EIP-20 one uses the version with _ while the Openzeppelin one does not
Steps To Reproduce
one with
another with
erc20Abi
from viemwriteContract
Link to Minimal Reproducible Example
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: