sei-chain icon indicating copy to clipboard operation
sei-chain copied to clipboard

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

Open dto-simba opened this issue 1 year ago • 10 comments

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 avatar Jul 31 '24 03:07 dto-simba

@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 avatar Aug 14 '24 21:08 philipsu522

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

philipsu522 avatar Aug 19 '24 21:08 philipsu522

@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.

dto-simba avatar Sep 02 '24 11:09 dto-simba

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 avatar Sep 02 '24 14:09 cordt-sei

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

codchen avatar Sep 10 '24 14:09 codchen

// 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;
    }
}

ARitz-Cracker avatar Sep 26 '24 14:09 ARitz-Cracker

@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?

dssei avatar Oct 01 '24 23:10 dssei

Could you please associate contract address as:

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

cordt-sei avatar Oct 02 '24 12:10 cordt-sei

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.

dssei avatar Oct 02 '24 16:10 dssei

ill take it from here!

Pray4Love1 avatar Jul 13 '25 09:07 Pray4Love1

Thank you for opening this issue and taking the time to share your thoughts. We’d love to keep moving this forward, but we need a bit more information from you. Please add any additional details within the next 2 day(s) so we can continue collaborating on a solution together. If we don’t hear back, the issue will close automatically — but you’re always welcome to reopen it when you’re ready.

github-actions[bot] avatar Nov 28 '25 12:11 github-actions[bot]

We’re closing this issue for now as we haven’t received additional input. Please know that your effort is appreciated — and when you’re ready to revisit this, we’ll be here to pick it up again. Thank you for contributing and helping us improve Sei.

github-actions[bot] avatar Nov 30 '25 12:11 github-actions[bot]