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.
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
we check if the block has already been used in
dmt-even
if it has we stop execution by throwing.we use the oracle to get the raw bytes of the current block.
we filter the bytes for all even numbers in it and count the length
to go from the count of even bytes to the mint amount we multiply it by the decimals. In this case 4 decimals
we use the
_internalMint
method to mint the correct amount to the senderwe 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
Last updated