Skip to content

Commit

Permalink
Add section on authoring a CDE
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed Oct 10, 2023
1 parent 7ade172 commit 5276569
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Create your own CDE

Although custom CDEs do not have to be added to Paima (people can just use the [generic CDE](./999-Generic.md), adding a CDE to Paima itself helps both with usability and with type inference.

To add a custom CDE to Paima, you need to do the following:

- (templates - optional) add your contract to `packages/contracts` if you think this contract should be bundled with Paima (useful for specifications like ERC20, etc. that might be reused often)


- fetcher (`@paima/funnel`): fetches your data from the blockchain
- updater (`@paima/sm`): handles creating updates for the Paima state machine / database when data for the CDE is found
- indexer (`@paima/db`): stores historical onchain CDE updates to the database for games to easily access
- config (`@paima/runtime`): handles parsing CDE config files users will write
- utils (`@paima/utils`): provides utility functions on top your CDE (ex: get all NFTs owned by a user)

With all these steps complete, your can create a pull request to the [Paima codebase](https://github.com/PaimaStudios/paima-engine/) so users can leverage your CDE!
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export async function getAllOwnedNfts(

## Capturing nft burn events

There is no separate nft burn event in the ERC721 contract, but a burn is just a transfer to the zero address (`'0x0000000000000000000000000000000000000000'`). Transfer events can be captured using a [generic CDE](./4-Generic.md) and then filtered based on the `to` address. Note that you will need to provide a built abi (it is built during deployment). Example of a generic extension entry:
There is no separate nft burn event in the ERC721 contract, but a burn is just a transfer to the zero address (`'0x0000000000000000000000000000000000000000'`). Transfer events can be captured using a [generic CDE](./999-Generic.md) and then filtered based on the `to` address. Note that you will need to provide a built abi (it is built during deployment). Example of a generic extension entry:
```yaml
- name: "NFT transfer"
type: generic
Expand Down

0 comments on commit 5276569

Please sign in to comment.