Skip to content

erc20 transfer function would create another transaction that differ from erc20's transaction and then lost important info #711

Closed
@powfulhong

Description

@powfulhong

What happened?

    let contractEthreumAddress = EthereumAddress(contractAddress)!
    let erc20 = ERC20(web3: web3, provider: web3.provider, address: contractEthreumAddress)
    guard let writeOP = try? await erc20.transfer(from: EthereumAddress(fromAddress)!, to: EthereumAddress(toAddress)!, amount: amount) else {
        return nil
    }
    
    var transaction = writeOP.transaction
    /// lose, need to add back
    transaction.from = erc20.transaction.from
    transaction.to = contractEthreumAddress
    transaction.callOnBlock = .latest

writeOP.transaction is different to erc20.transaction. They are 2 different instances. And writeOP.transaction lose the from & to & callOnBlock information.
if I donot add the last three codes, when I call web3.eth.send(raw),it just returns nil.

Library version

3.06

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions