LedgerManager

Git Source

Manages multiple Ledger contracts, facilitating cross-ledger transactions.

Acts as the owner of all managed Ledger contracts.

State Variables

transactionId

uint256 public transactionId;

ledgers

mapping(address => mapping(address => LedgerInfo)) public ledgers;

Functions

constructor

constructor();

createLedger

Deploy a new Ledger contract.

function createLedger(string memory name, Ledger.Category category) external returns (address ledgerAddress);

Parameters

Name
Type
Description

name

string

The name of the ledger (e.g., "Assets Ledger").

category

Ledger.Category

The type of accounts this ledger manages (Asset, Liability, etc.).

Returns

Name
Type
Description

ledgerAddress

address

The address of the newly deployed Ledger.

recordCrossLedgerDoubleEntry

Facilitates a double-entry transaction across ledgers if needed.

function recordCrossLedgerDoubleEntry(Ledger.Entry[] memory debits, Ledger.Entry[] memory credits) external;

Parameters

Name
Type
Description

debits

Ledger.Entry[]

An array of debit entries.

credits

Ledger.Entry[]

An array of credit entries.

getLedgersCount

Get the number of deployed Ledgers.

function getLedgersCount() external view returns (uint256 count);

Returns

Name
Type
Description

count

uint256

The total number of Ledgers managed.

Events

LedgerManagerCreated

event LedgerManagerCreated(address ledgerManagerAddress);

LedgerCreated

event LedgerCreated(address indexed id, address indexed owner, string name, Ledger.Category category);

DoubleEntryRecorded

event DoubleEntryRecorded(address author, Ledger.Entry[] debits, Ledger.Entry[] credits, uint256 transactionId);

Structs

LedgerInfo

struct LedgerInfo {
    address id;
    string name;
    Ledger.Category category;
    uint256 entryCount;
}

Last updated

Was this helpful?