I'm trying to call an FA1.2 transfer function from another contract. Here is my endpoint in the FA1.2 contract:
type action is
| Transfer of michelson_pair(address, "from", michelson_pair(address, "to", nat, "value"), "")
...
function main (const p : action ; const s : storage) : (list(operation) * storage) is
block {
if amount =/= 0tz then failwith ("This contract does not accept tezi deposits"); else skip;
} with case p of
| Transfer(n) -> ((nil : list(operation)), transfer(n.0, n.1.0, n.1.1, s))
| Approve(n) -> ((nil : list(operation)), approve(n.0, n.1, s))
| GetBalance(n) -> (get_balance(n.0, n.1, s), s)
| GetAllowance(n) -> (get_allowance(n.0.0, n.0.1, n.1, s), s)
| GetTotalSupply(n) -> (get_total_supply(n.1, s), s)
end
Here is how I try to call the contract. I define a type to call it:
type transfer_action is Transfer of michelson_pair(address, "from", michelson_pair(address, "to", nat, "value"), "")
and I try to get the entrypoint like this:
const token_contract: contract(transfer_action) = case (Tezos.get_entrypoint_opt("%transfer", storage.token_address): option(contract(transfer_action))) of
| Some (c) -> c
| None -> (failwith("incorrect contract") : contract(transfer_action))
end;
The call always fails with "incorrect contract"
. Calling GetBalance
for example works, but Approve
and Transfer
do not. I also tried "%transfer"
and "%Transfer"
.