-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from PaimaStudios/erc6551
Add erc6551 docs
- Loading branch information
Showing
3 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
docs/home/3-react-to-events/2-chain-data-extensions/4-ERC6551.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# ERC6551 CDEs | ||
|
||
- [ERC6551 Registry](#erc6551-registry), keeping track of registrations of Token-Bound Accounts (TBAs) on the chain | ||
|
||
## ERC6551 Registry | ||
|
||
### Example | ||
|
||
```yaml | ||
extensions: | ||
- name: "ERC6551 Registry" | ||
type: "erc6551-registry" | ||
contractAddress: "0x01...ef" # optional. Uses the standardized ERC6551 registry by default | ||
implementation: "0x01...ef" # optional. Filters to only TBAs created with a specific implementation | ||
tokenContract: "0x01...ef" # optional. Filters to only TBAs for a specific NFT collection | ||
tokenId: "1234" # optional. Filters to only TBAs for a specific token ID in the collection | ||
salt: "1234" # optional. Filters to only TBAs generated with a specific salt. Note: this is not an `indexed` field in the contract, so this will not lower the number of RPC calls | ||
startBlockHeight: 7654321 | ||
``` | ||
### Meaning | ||
ERC6551 uses a [global registry](https://eips.ethereum.org/EIPS/eip-6551#registry) that where all TBAs are registered. This address is constant among all chains, and acts as an easy way to know all the TBAs deployed to the chain | ||
This extension allows you to track all the TBAs that exist so that your game can easily aggregate state across different accounts owned by the same player, and it can allow you to treat specific kinds of TBA (ex: where the owner is a specific NFT for your game or a specific tool like [AWNS](https://www.stp.network)) differently. | ||
### Utility functions | ||
- `getErc6551AccountOwner`, fetch the NFT that owns this account: | ||
|
||
```ts | ||
export async function getErc6551AccountOwner( | ||
readonlyDBConn: PoolClient, | ||
cdeName: string, | ||
accountCreated: string | ||
): Promise<TokenIdPair | null>; | ||
``` | ||
|
||
- `getAllOwnedErc6551Accounts`, fetch all accounts owned by this NFT. This call is NOT recursive: | ||
|
||
```ts | ||
export async function getErc6551AccountOwner( | ||
readonlyDBConn: PoolClient, | ||
cdeName: string, | ||
nft: TokenIdPair | ||
): Promise<string[]>; | ||
``` |