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.

  • Can you share your code for reference? – Anuj P Feb 25 at 16:03
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)

| improve this answer | |
  • Yep, it works, thank you. – Daly Feb 5 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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