Specification and API of contracts