Hello guys I am trying to call from my contract entry point from FA2 token contract that I have deployed. But I am unable to find anything on the internet.

The only thing I found from the documentation is this

        from_ = alice.address,
        txs = [ sp.record(to=bob.address, amount=10, token_id=0),
                sp.record(to=bob.address, amount=10, token_id=1)]),
        from_ = bob.address,
        txs = [sp.record(to_=alice.address, amount=11, token_id=0)])]
).run(sender = charlie)

But I can’t find a way on how I can implement it from my entry point here

def exchange_tez(self):
    # Sanity checks
    sp.verify(sp.amount >= sp.tez(1), "INVALID AMOUNT")

1 Answer 1


I suggest you start by understanding how to call one contract from another. You can refer to this resource for more details: Call one contract from another.

In SmartPy, you have the ability to call a method in another contract by using sp.transfer.

c1.transfer is restrained to test scenario.

Here's the syntax for sp.transfer:

sp.transfer(argument: t, amount: sp.mutez, destination: sp.contract[t]):

  • argument is the same argument as c1.transfer
  • amount is an amount of tez (most of the time sp.tez(0))
  • destination is the destination contract, obtained by calling sp.contract(t, address: sp.address, entrypoint="transfer") and .unwrap_some().

Below is an example where I use these concepts. Note that I use t.transfer_params from the fa2_lib, but you can specify the full type directly:

        ).layout(("to_", ("token_id", "amount")))],
).layout(("from_", "txs"))]

Here is a full example:

import smartpy as sp
from templates import fa2_lib

# Accessing transfer_params from fa2_lib
t, main = fa2_lib.t, fa2_lib.main

def m():
    class MyContract(sp.Contract):
        def __init__(self):

        def call_transfer(self, fa2_address, args):
            # Get contract from the address
            fa2_contract = sp.contract(t.transfer_params, fa2_address, entrypoint="transfer")
            # Call the transfer entrypoint in the FA2 contract
            sp.transfer(args, sp.tez(0), fa2_contract.unwrap_some(error="Contract not found"))

if "templates" not in __name__:
    def test():
        sc = sp.test_scenario([t, main, m])
        c1 = m.MyContract()
        sc += c1
        fa2 = main.Fungible(sp.big_map(), {}, [])
        sc += fa2
        # Here we give the args
        # They can also be created inside the entrypoint.

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.