# NotaRegistrar

The full code can be seen on our [Github here](https://github.com/denotalabs/denota-protocol/blob/main/contracts/src/NotaRegistrar.sol).

## Abbreviated Code

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

```solidity
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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://denota.gitbook.io/denota/integration-development/protocol-reference/notaregistrar.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
