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

[BUG] The issue pertaining to transitioning from an ERC20 pointer to a CW20 contract #1797

Open
dto-simba opened this issue Jul 31, 2024 · 9 comments
Assignees
Labels
bug Something isn't working linear Created by Linear-GitHub Sync

Comments

@dto-simba
Copy link

Chain ID
atlantic-2 & pacific-1

Describe the bug
After creating a standard ERC20 token on EVM, the pointer converts to a CW20 contract. The invocation of the "send" method on the CW20 contract fails.

To Reproduce
Steps to reproduce the behavior:

  1. ERC20 address '0xf65F985ccBAB8aFaA34a8E15ddd070c0A29C2a51'
  2. Pointer cw20 address 'sei1r47t0rpwnm8uukmwr9c2rfxzxz73ntvenkp570s5y0p8gyamtxrqp2jj0c'
  3. See error
    Invocation of the 'send' method

Screenshots
sendError

@dto-simba dto-simba added bug Something isn't working linear Created by Linear-GitHub Sync labels Jul 31, 2024
@dto-simba dto-simba changed the title [BUG] Issue Title [BUG] The issue pertaining to transitioning from an ERC20 pointer to a CW20 contract Jul 31, 2024
@philipsu522
Copy link
Contributor

@dto-simba this seems like an issue with your account sequence number. Typically this can happen if a previous tx has failed. Is this still happening?

@philipsu522
Copy link
Contributor

Closing for now, feel free to reopen if you're still seeing issues

@dto-simba
Copy link
Author

@dto-simba this seems like an issue with your account sequence number. Typically this can happen if a previous tx has failed. Is this still happening?

It's not the nonce problem. I changed several addresses and got the same problem.

@cordt-sei
Copy link
Contributor

Confirmed on my end and tested fuirther, seems like an issue using pointers through contracts.

 # seid tx wasm execute sei1u9ftyhe5sszx9ghr7ae75ak05j86mme0xlzr0n4g0aa45hry5s0qlvr5nw \
'{"send":{"contract":"sei1v9hwx2zelwu9lha3al5d92d7u9hu7dc8naappzc7j3rl7uxw6xfs9vecvm","amount":"10","msg":"eyJzdGFrZSI6IHt9fQ=="}}' \
--from mine \
--chain-id atlantic-2 \
--gas 200000 \
--fees 500000usei \
--node https://rpc-testnet.sei-apis.com \
--broadcast-mode block
Enter keyring passphrase:
{"body":{"messages":[{"@type":"/cosmwasm.wasm.v1.MsgExecuteContract","sender":"sei1wev8ptzj27aueu04wgvvl4gvurax6rj5yrag90","contract":"sei1u9ftyhe5sszx9ghr7ae75ak05j86mme0xlzr0n4g0aa45hry5s0qlvr5nw","msg":{"send":{"contract":"sei1v9hwx2zelwu9lha3al5d92d7u9hu7dc8naappzc7j3rl7uxw6xfs9vecvm","amount":"10","msg":"eyJzdGFrZSI6IHt9fQ=="}},"funds":[]}],"memo":"","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[],"fee":{"amount":[{"denom":"usei","amount":"500000"}],"gas_limit":"200000","payer":"","granter":""}},"signatures":[]}

confirm transaction before signing and broadcasting [y/N]: y
code: 5
codespace: wasm
data: ""
events:
- attributes:
  - index: true
    key: c3BlbmRlcg==
    value: c2VpMXdldjhwdHpqMjdhdWV1MDR3Z3Z2bDRndnVyYXg2cmo1eXJhZzkw
  - index: true
    key: YW1vdW50
    value: NTAwMDAwdXNlaQ==
  type: coin_spent
- attributes:
  - index: true
    key: ZmVl
    value: NTAwMDAwdXNlaQ==
  - index: true
    key: ZmVlX3BheWVy
    value: c2VpMXdldjhwdHpqMjdhdWV1MDR3Z3Z2bDRndnVyYXg2cmo1eXJhZzkw
  type: tx
- attributes:
  - index: true
    key: YWNjX3NlcQ==
    value: c2VpMXdldjhwdHpqMjdhdWV1MDR3Z3Z2bDRndnVyYXg2cmo1eXJhZzkwLzE5
  type: tx
- attributes:
  - index: true
    key: c2lnbmF0dXJl
    value: TmxYbHJkQWY0NFU1QmV0UnFjckJaQ25aMXl2SE9ZT2Y4eTFzNGZMSGhDOVVjcStaejBIR0R6UUx0OUkxMEFiN0ZWQTlHanlFeEFVb1YxOGV6VTloU3c9PQ==
  type: tx
- attributes:
  - index: true
    key: ZXZtX2FkZHI=
    value: MHg0ZTFhZTYwMTc5OTcxMjhENDIxMDcwNGZCZTMxZDkwMzYyRjgxODFD
  - index: true
    key: c2VpX2FkZHI=
    value: c2VpMXdldjhwdHpqMjdhdWV1MDR3Z3Z2bDRndnVyYXg2cmo1eXJhZzkw
  type: signer
gas_used: "142316"
gas_wanted: "200000"
height: "114566417"
info: ""
logs: []
raw_log: 'failed to execute message; message index: 0: Generic error: Querier contract
  error: codespace: undefined, code: 1: execute wasm contract failed'
timestamp: ""
tx: null
txhash: 020D157A8A5E17C83E670B0BBC2531CB117FD49C19F33E83B4F8C953A385851F

@cordt-sei cordt-sei reopened this Sep 2, 2024
@codchen
Copy link
Collaborator

codchen commented Sep 10, 2024

@dto-simba is it possible for you to share the contract source used here? It would help us with root causing the issue

@ARitz-Cracker
Copy link

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract ERC20 {
    string public name = "Seipex Credits";
    string public symbol = "SPEX";
    uint8 public decimals = 18;
    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    constructor() {
        totalSupply = 420_000_000 * 10 ** uint256(decimals);
        balanceOf[msg.sender] = totalSupply;
        emit Transfer(address(0), msg.sender, totalSupply);
    }

    function transfer(address _to, uint256 _value) public returns (bool success) {
        require(_to != address(0), "Invalid address");
        require(balanceOf[msg.sender] >= _value, "Insufficient balance");

        balanceOf[msg.sender] -= _value;
        balanceOf[_to] += _value;

        emit Transfer(msg.sender, _to, _value);
        return true;
    }

    function approve(address _spender, uint256 _value) public returns (bool success) {
        require(_spender != address(0), "Invalid address");

        allowance[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        require(_to != address(0), "Invalid address");
        require(balanceOf[_from] >= _value, "Insufficient balance");
        require(allowance[_from][msg.sender] >= _value, "Allowance exceeded");

        balanceOf[_from] -= _value;
        balanceOf[_to] += _value;
        allowance[_from][msg.sender] -= _value;

        emit Transfer(_from, _to, _value);
        return true;
    }
}

@dssei dssei self-assigned this Oct 1, 2024
@dssei
Copy link
Contributor

dssei commented Oct 1, 2024

@dto-simba we think that possible issue cause is the lack of wasm contract association to an EVM address, that is required when send method is translated to the EVM transfer.

Could you please associate contract address as:

seid tx evm associate-contract-address <wasm_contract_address_that_implements_receive> --from <sei_address> --fees 20000usei -b block

and then re-invoke the pointer contract?

@cordt-sei
Copy link
Contributor

Could you please associate contract address as:

Wait.. that's the purpose of the associated contract addresses? Is this written anywhere?

@dssei
Copy link
Contributor

dssei commented Oct 2, 2024

Could you please associate contract address as:

Wait.. that's the purpose of the associated contract addresses? Is this written anywhere?

For this specific case of sending funds to a contract address, contract address has to have associated EVM address, similar to what we have for regular addresses.
We constantly working on improving the documentation and will cover this case soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linear Created by Linear-GitHub Sync
Projects
None yet
Development

No branches or pull requests

6 participants