🏗️NotaRegistrar

The guts of the protocol

The full code can be seen on our Github here.

Abbreviated Code

Here is the structure of the main functions that explain how the registrar works in simpler terms.

contract NotaRegistrar {

    // Mint a Nota and escrow tokens inside
    function write(currencyAddress, escrowedAmount, instantAmount, ownerAddress, hookAddress, hookBytes) {
        validateWrite(currencyAddress, hookAddress);
        
        // Reverts on validation OR hookBytes is stored on the hook
        hookFee = hookAddress.beforeWrite();
        
        transferEscrowAndInstantTokens();
        mintNotaToOwner();
        increaseHookRevenue();
        
        emit Write();
        return incrementedTotalSupply();
    }

    // Transfer your Nota to another owner
    function safeTransferFrom(fromAddress, toAddress, notaId, hookBytes) {
        // Reverts on validation OR hookBytes is stored on the hook
        hookFee = nota.hook.beforeTransfer();
        
        reduceNotaEscrow();
        increaseHookRevenue();
        ERC721.safeTransferFrom();
    }

    // Add more tokens inside your Nota
    function fund(notaId, escrowAmount, instantAmount, hookBytes) {
        // Reverts on validation OR hookBytes is stored on the hook
        hookFee = nota.hook.beforeFund();

        transferEscrowAndInstantTokens();
        increaseNotaEscrow();
        increaseHookRevenue();
        
        emit Fund();
    }

    // Remove tokens from inside your Nota
    function cash(notaId, cashAmount, recipientAddress, hookBytes) {
        // Reverts on validation OR hookBytes is stored on the hook
        hookFee = nota.hook.beforeCash();

        decreaseNotaEscrow();
        unEscrowCashingAmount();
        increaseHookRevenue();

        emit Cash();
    }

    // Approve an address to transfer your Nota
    function approve(approvedAddress, notaId) {
        // Reverts on validation OR hookBytes is stored on the hook
        hookFee = nota.hook.beforeApprove();
        
        decreaseNotaEscrow();
        increaseHookRevenue();
        
        ERC721.approve();
    }

    // Get metadata about your Nota
    function tokenURI(notaId) {
        HookJSONString = nota.hook.beforeTokenURI();
        
        return constructNotaJSON(notaId, JSONString);
    }
}

Note that transferFrom() is the exact same as safeTransferFrom() but with empty bytes for the bytesData parameter.

Last updated