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

Increase allowance in an ERC20 token #903

Closed
gabrielfior opened this issue Apr 12, 2024 · 1 comment
Closed

Increase allowance in an ERC20 token #903

gabrielfior opened this issue Apr 12, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@gabrielfior
Copy link

Describe the bug
I want to call the method approve (described below) having the Safe as sender (tx['from']), effectively increasing the allowance given to the spender.

approve(address spender, uint256 amount) → bool

I might be confused about the Safe inner workings, but I don't think it's currently possible to have the Safe sign a transaction (please see steps to reproduce below).

To Reproduce
Steps to reproduce the behavior:

spender = "0x1234" # EOA account
    wxDAI = web3.eth.contract(address=contract_address, abi=contract_abi)
 tx_params = {}
    tx_params["nonce"] = tx_params.get(
        "nonce", web3.eth.get_transaction_count(from_address)
    )
    tx_params["from"] = SAFE_ADDRESS 
    approve_tx = wxDAI.functions.approve(
        Web3.to_checksum_address(spender), # spender here is another EOA, e.g. my own address
        int(1e18),
).build_transaction(tx_params)

    signed_approve = w3.eth.account.sign_transaction(
        approve_tx, private_key=SAFE_PRIVATE_KEY
    )
    approve_tx_hash = w3.eth.send_raw_transaction(signed_approve.rawTransaction)

Expected behavior
I expected the raw transaction to be submitted, but it's unclear how to complete transactions with a Safe's signature using web3py.

I appreciate your help in this topic.

@gabrielfior gabrielfior added the bug Something isn't working label Apr 12, 2024
@Uxio0
Copy link
Member

Uxio0 commented Apr 15, 2024

A Safe does not use a Private key. You need to understand a little better how Safe works. You can take a look at https://github.com/safe-global/safe-cli/ to see how it handles ERC20 token sending, for example. We are adding more examples to our documentation, in the meantime you can check the CLI one: https://docs.safe.global/advanced/cli-reference/common-commands

@Uxio0 Uxio0 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants