3

Can someone please give an example Michelson smart contract that calls another smart contract ?

Some actual implementation would go a long way.

Many thanks

2

An example in Michelson

Take one contract

parameter (option string) ;
storage (contract string) ;
code
 {
    UNPAIR ; DIP { DUP } ;
    IF_SOME { } { PUSH string "hello, world" } ;
    PUSH mutez 0 ; SWAP ;
    TRANSFER_TOKENS ;
    NIL operation ; SWAP ; CONS ;
    PAIR
 }

and another

parameter string ;
storage string ;
code
  {
    UNPAIR ;
    SWAP ;
    DROP ;
    NIL operation ;
    PAIR  ;
  }

The first contract takes an optional string parameter and calls the contract in its storage with that string, or "hello, world" if none was provided. The second contract takes a string as input and puts it in its storage.

2

Go to liquidity ide and compile that

  • On Stack Exchange it is better to offer responses inline rather than just pointing to a link to some external resources if the size of the answer is not too big. The reason is because links are weak and can expire over time so your answer may become invalid sometime in the future. – Ezy Feb 3 at 15:54
  • It is also useful to play with the contracts, thanks! – FFF Feb 5 at 0:08

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.