OpenZeppelin provides the SafeERC20 Solidity library as a way to handle the possible variations of ERC20. Is there an equivalent way to do this using Vyper?

1 Answer 1


Starting with Vyper 0.2.0 this is possible using the raw_call builtin function:

def safe_transfer(_token: address, _to: address, _value: uint256) -> bool:
    _response: Bytes[32] = raw_call(
            convert(_to, bytes32),
            convert(_value, bytes32)
    if len(_response) > 0:
        assert convert(_response, bool), "Transfer failed!"

    return True

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.