Skip to content

Commit

Permalink
add docs for cardano's transfer and mint and burn
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Mar 19, 2024
1 parent 183c0c0 commit 7608e5c
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extensions:
startSlot: 32815320
stopSlot: 32815924
scheduledPrefix: cd
network: CardanoNetworkConfigEntryName
```
### Meaning
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Delayed State

Different blockchains may have different block times & finality, so trying to guarantee the state of blockchain A from blockchain B often requires timelock systems like [projected data](../../../700-multichain-support/1-nfts/2-projected-nfts/1-basics.mdx).
Different blockchains may have different block times & finality, so trying to guarantee the state of blockchain A from blockchain B often requires timelock systems like [projected data](../../../700-multichain-support/1-projected-nfts/1-introduction.mdx).

However, not all use-cases care about having the data entirely up-to-date. For example, NFT-gated features should work even if your knowledge of whether or not the user owns an NFT is 5 minutes delayed. That is to say, delayed data is **not** guaranteed to be up-to-date (hence *delayed*)

Expand All @@ -23,6 +23,7 @@ extensions:
- "919d4c2c9455016289341b1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
startSlot: 22505578
stopSlot: 32815924
network: CardanoNetworkConfigEntryName
```
### Meaning
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

# Cardano Transfer {#transfer}

### Example

```yaml
extensions:
- name: "CardanoTransfer"
type: cardano-transfer
credential: addr_test1qp27ms6du9e2fga6njk9ruzprp7gg3uddrnc3htv7mct8kwrwdlnpt07ycmdqyuw7lft338dt33tmr6xdwnn8ezsudpquved20
startSlot: 12472120
stopSlot: 12500000
scheduledPrefix: ct
network: CardanoNetworkConfigEntryName
```
### Meaning
- `startSlot` is required and means that only transactions that happen after that slot (exclusive) will be considered.
- `stopSlot` is optional, and it stops the indexing at that point.
- `credential` is the address to track. This can be a bech32 address, or a hex encoded credential.

### Paima Concise format

The scheduled input for each event is of the following form.

```
cardanoTransfer = ct|txId|metadata|inputCredentials|outputs
```
It can be parsed with a rule of the form:
```ts
const cardanoTransfer: ParserRecord<CardanoTransfer> = {
txId: PaimaParser.NCharsParser(0, 64),
metadata: PaimaParser.OptionalParser(null, PaimaParser.RegexParser(/[a-f0-9]*/)),
inputCredentials: PaimaParser.ArrayParser({
item: PaimaParser.RegexParser(/[a-f0-9]*/),
}),
outputs: (keyName: string, input: string) => {
return JSON.parse(input);
},
};
interface CardanoTransfer {
txId: string;
metadata: string | null;
inputCredentials: string[];
outputs: {
asset: { policyId: string; assetName: string } | null;
amount: string;
address: string;
}[];
}
```

- The metadata field is in its binary form, but hex encoded.
- The entries in `inputCredentials` are also hex encoded. Each one is the binary
representation of the payment key (64 characters or 32 bytes).
- `outputs` preserves the same order as in the binary transaction. The `asset`
will be `null` when the amount is in lovelace.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Cardano Mint and Burn {#mint-burn}

### Example

```yaml
extensions:
- name: "CARDANO-MINT-BURN"
type: cardano-mint-burn
policyIds:
- "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91fe"
- "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91ff"
startSlot: 722300
stopSlot: 733216
scheduledPrefix: cmb
network: CardanoNetworkConfigEntryName
```
### Meaning
- `startSlot` is required and means that only mints events after that slot (exclusive) will be considered.
- `stopSlot` is optional, and it stops the indexing at that point.
- `policyIds` is an array with the collections to index.

### Paima Concise format

The scheduled input for each event is of the following form.

```
cardanoMint = cmb|txId|metadata|assets
```
It can be parsed with a rule of the form:
```ts
const cardanoMint: ParserRecord<CardanoMint> = {
txId: PaimaParser.NCharsParser(0, 64),
metadata: PaimaParser.OptionalParser(null, PaimaParser.RegexParser(/[a-f0-9]*/)),
assets: (keyName: string, input: string) => {
return JSON.parse(input);
},
};
export interface CardanoMint {
txId: string;
metadata: string | null;
assets: { asset: { policyId: string; assetName: string }; amount: string };
}
```

- The `metadata` field is hex encoded (if any), and it's the metadata in binary
form.
- The `assets` field has the minted or burned assets. The difference between a
mint and a burn is in the sign of `amount` when interpreted as a number.

0 comments on commit 7608e5c

Please sign in to comment.