Vyper: Payable methods with Contract Interfaces

Created on 2 May 2018  路  5Comments  路  Source: vyperlang/vyper

I am experimenting with external calls using contract interfaces, and can't seem to figure out payable functions. Adding a test example would be helpful. https://github.com/ethereum/vyper/blob/9eebb7c575545fcf880d815b9c888665dccbea51/tests/parser/features/external_contracts/test_external_contract_calls.py#L1

This works:

# FACTORY CONTRACT
class Exchange():
    def setup(token_addr: address) -> bool: pass

@public
def launch_exchange(token_addr: address) -> address:
    exchange_addr: address = create_with_code_of(self.exchange_template)
    assert Exchange(exchange_addr).setup(token_addr) == True

# EXCHANGE CONTRACT
@public
def setup(token_addr: address) -> bool:
    self.token_address = token_addr
    return True

I tried making the functions payable, and changing the call to

assert Exchange(exchange_addr).setup(token_addr, value=msg.value) == True

and the function still executes, but no ETH is transferred. I'm wondering if this is possible, and what the proper syntax is.

EDIT: forgot cute animal picture

image

bug

Most helpful comment

That's what I thought, just wanted to make sure I wasn't forgetting anything

All 5 comments

Looking at the source code, it seems like external contracts always has their wei value set to zero:
https://github.com/ethereum/vyper/blob/master/vyper/parser/parser.py#L534
Will have to add a parameter to support this. value= kwarg seems natural.

@jacqueswww would we support any other calling parameters?

We could, only other one is gas right?

I believe in Solidity gas and value are the only two additional parameters for calls using interfaces.

That's what I thought, just wanted to make sure I wasn't forgetting anything

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robinsierra picture robinsierra  路  3Comments

lsaether picture lsaether  路  4Comments

fubuloubu picture fubuloubu  路  3Comments

denis-bogdanas picture denis-bogdanas  路  3Comments

pipermerriam picture pipermerriam  路  3Comments