JavaScript client to interface with resources in the Spec ecosystem.
- Node.js >= 16
- npm >= 8
$ npm install @spec.dev/ecosystem
In order to make changes within your namespace on Spec, you will first need a namespace access token.
It's important to keep this token private — and because of this, any write operations performed by this library should be initiated on the server-side, with your token stored as an environment variable.
Creating a new instance of the ecosystem client is simple.
import { SpecEcosystemClient } from '@spec.dev/ecosystem'
const spec = new SpecEcosystemClient({
namespaceToken: process.env.SPEC_NAMESPACE_TOKEN
})
Currently, this library can be used:
- Create new contract groups
- Add new contracts to an existing group
const group = 'namespace.ContractName'
const chainIds = [1, 5, 137, ...] // chain ids for the group
const abi = [{ type: 'event', name: 'Transfer', ... }, ...]
const { ok, error } = await spec.createContractGroup(group, chainIds, abi)
Note
The contract group must exist before using this method to add contracts to it.
Currently, only a single chain can be used per API call. This may change in the near future, so stay tuned.
const group = 'namespace.ContractName'
const chainId = 5
const addresses = ['0x123...', '0x456...']
const { ok, error } = await spec.addContractsToGroup(group, chainId, addresses)
MIT