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

Set allowance during ERC-20 deposit #22

Open
1 task
tuler opened this issue May 8, 2024 · 0 comments
Open
1 task

Set allowance during ERC-20 deposit #22

tuler opened this issue May 8, 2024 · 0 comments

Comments

@tuler
Copy link
Member

tuler commented May 8, 2024

πŸ“š Context

The ERC-20 contract requires to set an allowance before depositing tokens into the ERC20Portal contract.
cartesi send erc20 does not handle allowance, so it often fails like so:

➜  cartesi-app cartesi send
? Select send sub-command Send ERC-20 deposit to the application.
? Chain Foundry
? RPC URL http://127.0.0.1:8545
? Wallet Mnemonic
? Mnemonic test test test test test test test test test test test junk
? Account 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 9999.964983134519619707 ETH
? Application address 0xab7528bb862fb57e8a2bcd567a2e929a0be56a5e
? Token address 0x92C6bcA388E99d6B304f1Af3c3Cd749Ff0b591e2
? Amount 1
    ContractFunctionExecutionError: The contract function "depositERC20Tokens" reverted with the following signature:
    0xfb8f41b2

    Unable to decode signature "0xfb8f41b2" as it was not found on the provided ABI.
    Make sure you are using the correct ABI and that the error exists on it.
    You can look up the decoded signature here: https://openchain.xyz/signatures?query=0xfb8f41b2.
 
    Contract Call:
      address:   0x9C21AEb2093C32DDbC53eEF24B873BDCd1aDa1DB
      function:  depositERC20Tokens(address _token, address _dapp, uint256 _amount, bytes _execLayerData)
      args:                        (0x92C6bcA388E99d6B304f1Af3c3Cd749Ff0b591e2, 0xab7528bb862fb57e8a2bcd567a2e929a0be56a5e, 1000000000000000000, 0x)
      sender:    0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

    Docs: https://viem.sh/docs/contract/decodeErrorResult
    Version: [email protected]

βœ”οΈ Solution

cartesi send erc20 could also take care of the allowance transaction.

🎯 Definition of Done

  • send erc20 asks for allowance if necessary, and send the allowance transaction before sending the ERC20Portal transaction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant