Aleo for Agents is offline at present

glossary·2026-08-03·2 min read

Import

Import

An import statement lets one Leo program call entry points in another deployed program. Import statements live outside the program { } block.

leo
import credits.aleo;

program payment.aleo {
    @noupgrade
    constructor() {}

    mapping payments: address => u64;

    fn pay(public receiver: address, public amount: u64) -> Final {
        // Calling a stateful entry point returns a Final handle
        let transfer: Final = credits.aleo::transfer_public(receiver, amount);

        return final {
            // Run the callee's finalization before your own
            transfer.run();

            let total: u64 = payments.get_or_use(receiver, 0u64);
            payments.set(receiver, total + amount);
        };
    }
}

The separator is ::. Leo 4.0 replaced the older credits.aleo/transfer_public form, and that applies to every cross-program reference: function calls, type annotations, and reads of another program's mappings or storage.

Add the dependency before you build:

bash
leo add credits.aleo --network
leo add my_lib.aleo --local ../my_lib

Imports resolve statically at compile time, so the imported program must be deployed before yours. Each program still generates its own proof; composability here means calling across program boundaries, not merging circuits.

A program can read another program's mappings but cannot write them. Leo 4.4 rejects cross-program final calls that would write another program's state, and the check follows transitive calls, so hiding the write behind a helper does not get around it.

Check the per-import size lines that leo build prints. An import you added for one helper carries its whole compiled body into your deployment cost.

Sources