sui-bcs-2
v2.0.0
Published
This tool generates BCS types for the Sui blockchain. It fetches the Move modules of a specified package over the [Sui GraphQL API](https://docs.sui.io/references/sui-graphql) and creates the corresponding BCS type definitions in JavaScript.
Readme
Sui BCS Type Generator
This tool generates BCS types for the Sui blockchain. It fetches the Move modules of a specified package over the Sui GraphQL API and creates the corresponding BCS type definitions in JavaScript.
Forked from https://github.com/Sceat/sui-bcs Improved with Enum support, TypeName and String handling.
Usage
To generate BCS types, use the following command:
npx sui-bcs-2 gen --package <package_address> --file <output_file> --network <network_name>--package <package_address>: The address of the package from which to fetch the Move modules.--file <output_file>: The name of the file to write the generated BCS types to.--network <network_name>: The network to use, one ofmainnet,testnet,devnet,localnet(default:testnet).--url <url>: A GraphQL endpoint to use instead of the built-in one for--network. Useful for a self-hosted service or a third party RPC provider.
Example:
npx sui-bcs-2 gen --package 0x2 --file sui-bcs.js --network testnet
GraphQL
The generator talks to the GraphQL API rather than JSON-RPC, which Sui has decommissioned on public fullnodes. The default endpoints are:
| Network | Endpoint |
| -------- | ---------------------------------------- |
| mainnet | https://graphql.mainnet.sui.io/graphql |
| testnet | https://graphql.testnet.sui.io/graphql |
| devnet | https://graphql.devnet.sui.io/graphql |
| localnet | http://127.0.0.1:9125/graphql |
For a localnet, start the service with sui start --with-graphql.
