Contract Interfaces
// Declare a contract interface that declares an interface and a resource
// that needs to implement that interface in the contract implementation.
//
pub contract interface InterfaceExample {
// Implementations do not need to declare this
// They refer to it as InterfaceExample.NestedInterface
//
pub resource interface NestedInterface {}
// Implementations must declare this type
//
pub resource Composite: NestedInterface {}
}
pub contract ExampleContract: InterfaceExample {
// The contract doesn't need to redeclare the `NestedInterface` interface
// because it is already declared in the contract interface
// The resource has to refer to the resource interface using the name
// of the contract interface to access it
//
pub resource Composite: InterfaceExample.NestedInterface {
}
}Last updated