Entry Function

An entry function visibility modifier restricts calling a function from another package but allows direct calls in a transaction block. Entry functions can't return a value that doesn't have drop ability.

module examples::object {
    /// An object is a struct with `key` ability and `id: UID` field.
    public struct Object has key {
        id: UID

    /// If function is defined as public - any module can call it.
    /// Non-entry functions are also allowed to have return values.
    public fun create(ctx: &mut TxContext): Object {
        Object { id: object::new(ctx) }

    /// Entrypoints can't have return values as they can only be called
    /// directly in a transaction and the returned value can't be used.
    /// However, `entry` without `public` disallows calling this method from
    /// other Move modules.
    entry fun create_and_transfer(to: address, ctx: &mut TxContext) {
        transfer::transfer(create(ctx), to)

Entry functions can be public, and that would make them callable from other modules. However, the return value restrictions still apply.

Learn more