Commit 45c15633 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #4986 from ethereum-optimism/02-25-documentation

feat(atst): Add documentation for the attestation station sdk
parents 628324b8 e3a2563c
......@@ -32,7 +32,7 @@ npm install @eth-optimism/atst wagmi @wagmi/core ethers@5.7.0
The typescript sdk provides a clean [wagmi](https://wagmi.sh/) based interface for reading and writing to the attestation station
### See [sdk docs]() for usage instructions
### See [sdk docs](https://github.com/ethereum-optimism/optimism/blob/develop/packages/atst/docs/sdk.md) for usage instructions
## atst cli
......@@ -40,16 +40,28 @@ The cli provides a convenient cli for interacting with the attestation station c
TODO put a gif here of using it
## React instructions
## React API
For react hooks we recomend using the [wagmi cli](https://wagmi.sh/cli/getting-started) with the [etherscan plugin](https://wagmi.sh/cli/plugins/etherscan) and [react plugin](https://wagmi.sh/cli/plugins/react) to automatically generate react hooks around the attestation station. See [example/react](http://todo.todo.todo) for an example.
For react hooks we recomend using the [wagmi cli](https://wagmi.sh/cli/getting-started) with the [etherscan plugin](https://wagmi.sh/cli/plugins/etherscan) and [react plugin](https://wagmi.sh/cli/plugins/react) to automatically generate react hooks around the attestation station.
Use `parseAttestationBytes` and `stringifyAttestationBytes` to parse and stringify attestations before passing them into wagmi hooks.
For convenience we also export the hooks here.
`useAttestationStationAttestation` - Reads attestations with useContractRead
`useAttestationStationVersion` - Reads attestation version
`useAttestationStationAttest` - Wraps useContractWrite with attestation station abi calling attest
`usePrepareAttestationStationAttest` - Wraps usePrepare with attestation station abi calling attest
`useAttestationStationAttestationCreatedEvent` - Wraps useContractEvents for Created events
Also some more hooks exported by the cli but these are likely the only ones you need.
## Contributing
Please see our [contributing.md](/docs/contributing.md). No contribution is too small.
Please see our [contributing.md](docs/contributing.md). No contribution is too small.
Having your contribution denied feels bad. Please consider opening an issue before adding any new features or apis
## Check [Awesome ATST](https://todo.todo.todo) for awesome tools and examples around the attestation station
......@@ -52,21 +52,26 @@ createClient({
### Reading an attestation
To read an attestation use `readString`, `readAddress`, `readNumber`, `readBool`
Use `readAttestationString` with `bytes` passed in for the types parameter to read raw bytes
Here is an example of reading an attestation used by the optimist nft
```typescript
import { readAttestation } from '@eth-optimism/atst'
import { readAttestationString } from '@eth-optimism/atst'
const creator = '0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3'
const about = '0x2335022c740d17c2837f9C884Bfe4fFdbf0A95D5'
const key = 'optimist.base-uri'
const dataType = 'string' // note string is default
const attestation = await readAttestation(creator, about, key, dataType)
const str = await readAttestationString(creator, about, key)
console.log(attestation) // https://assets.optimism.io/4a609661-6774-441f-9fdb-453fdbb89931-bucket/optimist-nft/attributes
```
### Reading multiple Attestations
If reading more than one attestation you can use readAttestations to read them with multicall
### Writing an attestation
......@@ -172,11 +177,16 @@ const attestation = await readAttestations({
})
```
### parseAttestationBytes
### Parsing bytes
These utilities for parsing bytes are provided:
Parses raw bytes from the attestation station based on the type.
`parseAddress`
`parseNumber`
`parseBool`
`parseString`
Note: `readAttestation` and `readAttestations` already parse the bytes so this is only necessary if reading attestations directly from chain instead of through this sdkA
Note: `readAttestation` and `readAttestations` already parse the bytes so this is only necessary if reading attestations directly from chain instead of through this utility
```typescript
const attestation = parseAttestationBytes(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment