4

I would like to send tez to my smart contract, I tried from the temple interface but it does not work, I think it is because it is a contract address and not a simple address of wallet... Do you know another way?

Thank you for your attention and thank you for your help

3 Answers 3

2

You'll need to implement the default entrypoint. If you're writing in CamelLIGO, here's a sample of how it would be implemented:

let main (param, storage : entrypoint * contract_storage) : operation list * contract_storage =
    match param with
    | Withdraw recipient ->
        let () = if Tezos.amount > 0tez
        then failwith "If you'd like to send funds; you're invoking the wrong function"
        in withdraw(recipient, storage)
    | Default _d -> ([]: operation list), storage

There's more discussion at https://help.sweet.io/en/articles/5884308-sending-funds-to-a-blockchain-payment-contract

3

To have the same transfer behavior on originated contracts (KT1... addresses) as on implicit accounts (tz{1,2,3}... addresses), you will need to add a default entrypoint with unit input.

(unit %default)
2
  • the default (unit) parameter is represented like this in storage: { } ?
    – oriana
    Mar 22 at 15:51
  • It is not in the storage. It is just an entrypoint named default that has unit as input type. Mar 22 at 15:54
1

If you're using SmartPy you can add the default entrypoint to your contract like this:

@sp.entry_point()
def default(self, params):
    sp.set_type(params, sp.TUnit)

Once that is in place your contract will be able to receive funds directly.

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.