As said in Quick Start (please check, if you don't know what is going on here), Contract command looks like:

'Contract' command

Let's consider syntax of basic 'Contract' command, which allows introducing contract description on Ursus lang.

'Contract' ContractName ';'
'Send To' InterfaceName1 InterfaceName2 ';'
'Types'
   'Record' Name1Record ':= {'
      Name1RecordMemberName ':' Type1 ';'
      Name1RecordMemberName ':' Type2 ';'
      ... 
      NameNRecordMemberName ':' TypeN 
   }
   'Record' Name2Record ':= {'
      ...
   } 
   ...
   'Record' NameLastRecord ':= {'
      ...
   } 
';'
'Constants'
   'Definition' Constant1Name ':' Type1 ':=' value1
   'Definition' Constant2Name ':' Type2 ':=' value2
   ...
   'Definition' ConstantLastName ':' TypeLast ':=' valueLast 
';'
'Record Contract' ':= {'
   '#[' AccessRights ']' Name1ContractMember ':' Type1 ';'
   '#[' AccessRights ']' Name2ContractMember ':' Type2 ';'
   ...
   NameNContractMember ':' TypeN
'}.'

For example:

Contract MultisigWallet ;
Sends To  Itmp ; 
Types 
  Record Transaction := {
    Transaction_ι_id : uint64;
    Transaction_ι_confirmationsMask : uint32;
   }
   Record UpdateRequest := {
      UpdateRequest_ι_id : uint64;
      UpdateRequest_ι_index : uint8;
      UpdateRequest_ι_signs : uint8;
      trans : (_ResolveName "Transaction");
   };
Constants 
   Definition FLAG_SEND_ALL_REMAINING : uint8 := 128
   Definition FLAG_IGNORE_ERRORS : uint8 := 2
;
Record Contract := {
   #[static] _pubkey : uint256;
   #[static] _foo : uint256;
   m_requiredVotes :  uint8;
   m_defaultRequiredConfirmations :  uint8;
   last_transaction : (_ResolveName "Transaction")
}.

Let's consider more precisely this command with each section:

  1. After keyword Contract here is name of the described contract
  2. Keyword Sends To is used to declare which interfaces are used for sending messages.
  3. Keyword Types is used to declare new strutures that will be used below.
  4. Keyword Constant is used to declare constants, which will be used in the contract. Important to mention that value, which will be assignment here must be literal.
  5. Record Contract contains fields of the contract, which can have attribute #[public],#[static] or nothing. It's important(!) to use custom type/structures here with wrapper _ResolveName because Contract command doesn't know such types before creating all notations.

This part was expressed in Quick Start too.

After command Contract it needs to use command SetUrsusOptions. and UseLocal ... . In the UseLocal list important to notice that customtypes must be used with special name. For example, if you have structure name Foo, you need to use FooLRecord name.

Next is going to describe function and modifier declaration, but there.

End of declaring contract comes with two command EndContract Implements Interface1 Interface2 ... . and End ContactName. where:

  1. ContractName is module name, which this contract located;
  2. Interface1 and Interface2 are implemented interfaces, which means that signatures and function names from these interfaces are the same as in folowing interfaces.

In the last version is possible to create interface using signatures of declared contract via command EndContract ImplementsAuto.

Read there for getting information about built-in types in Ursus.