Entry functions can be called directly from transactions:
/// Entry functions can accept a reference to the `TxContext`/// (mutable or immutable) as their last parameter.entry fun share(bar: u64, ctx: &mut TxContext) { transfer::share_object(Foo { id: object::new(ctx), bar, })}/// Entry functions can return types that have `drop`.entry fun bar(foo: &Foo): u64 { foo.bar}
Entry functions cannot return types without drop ability. They also have restrictions when used in Programmable Transaction Blocks.
public fun with_context(ctx: &TxContext) { let sender = ctx.sender(); let epoch = ctx.epoch();}public fun create(ctx: &mut TxContext) { let id = object::new(ctx); // Needs mutable ctx}
public fun wrap<T: store>(value: T): Box<T> { Box { value }}public fun unwrap<T: store>(box: Box<T>): T { let Box { value } = box; value}// Multiple type parameterspublic fun pair<T: store, U: store>(t: T, u: U): Pair<T, U> { Pair { first: t, second: u }}