# Digital Matter Theory

Lambda Protocol has first class for DMT. It makes it especially simple as everything can be done inside a smart contract and there is no need to create any infrastructure to achieve your goal.

### Oracle

Lambda Protocol offers you an oracle inside a smart contract function, one of the oracles method is `getRawBlock` which returns an `UInt8Array`. This array of bytes can be used for any kind of pattern matching, seeding, and so on.

### Example: dmt-even

We currently have one smart contract live using the oracle for dmt. Lets go over the code to see how simple it is.

```typescript
import { LRC20Base } from "./standards/base/LRC20Base.ts";
import { Contract, ContractParams } from "./types/contract.ts";
import { ExecutionError } from "./types/execution-error.ts";

export default class DmtEven extends LRC20Base implements Contract {
  _blocksMinted = new Set<number>();

  constructor() {
    super("DMT-EVEN", "DMT-EVEN", 4, "0x0", 833000);
  }

  protected async mintLogic({
    metadata,
    eventLogger,
    oracle,
  }: ContractParams): Promise<void> {
    if (this._blocksMinted.has(metadata.blockNumber))
      throw new ExecutionError("mint: Block already minted");
    const block = await oracle.getRawBlock(metadata.blockNumber);
    const evenNumbers = block.filter((x) => x % 2 === 0).length;

    const amount = BigInt(evenNumbers * 1_0000);
    this._internalMint(metadata.sender, amount, eventLogger);

    this._blocksMinted.add(metadata.blockNumber);
  }
}
```

As you can see the contract is for a token called `DMT-EVEN`, this can be done easily by extending our `LRC20Base`, the LRC20 standard implementation of tokens. However, we want to change the mint logic, to make it mint a specific amount based on pattern matching.

The logic for DMT-EVEN minting is

1. we check if the block has already been used in `dmt-even` if it has we stop execution by throwing.
2. we use the oracle to get the raw bytes of the current block.
3. we filter the bytes for all even numbers in it and count the length
4. to go from the count of even bytes to the mint amount we multiply it by the decimals. In this case 4 decimals
5. we use the `_internalMint` method to mint the correct amount to the sender
6. we add the block number to the `_blocksMinted` set to ensure it is not used again

As you can see it is really simple to do dmt stuff on Lambda Protocol
