1

How can I call a smart contract method from another smart contract with smartPy?

Use Case:

Lest's imagine that we have:

  1. Smart contract with a function increment(a)
  2. Smart contract with a function changeVarValue() that invokes the first Smart Contract's increment method.

Many thanks.

1
  • Can you share your code for reference?
    – Anuj P
    Feb 25, 2020 at 16:03

1 Answer 1

1

There is an example template here: https://smartpy.io/dev/index.html?template=collatz.py.

The documentation is here: http://smartpy.io/dev/reference.html#_contract_and_address.

Basically:

  • define your target contract

  • c = sp.contract(sp.TInt, address_of_the_target_contract, entry_point = "foo").open_some()

  • use sp.transfer(-42, sp.mutez(0), c)

0

Your Answer

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

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