When reading the documentation, the explanation of the protocol contracts is great. However, developers have to setup a basic testing environment to interact with the contracts to better understand the behavior.
The widget eliminates this by enabling developers to interact with the contract methods directly within the documentation. This greatly reduces integration time and the context switching that would otherwise be required, making protocols more developer-friendly.
Bonadocs widget allows you to enable interactivity within your docs through widgets.
Let’s first install our bonadocs CLI. This CLI allows you to generate the necessary widgets for your documentation.
npm install -g @bonadocs/cli
After installation, we need to create a collection. You can think about a collection the same way you think about a protocol. It's simply a protocol that can have smart contract(s) as children.
bonadocs collections create
You’ll get prompted to add the name and description of the collection. After successful collection creation, it returns a unique id. In this case, it’s 0xb52b23ce
.
Creation of a protocol called NFT-Protocol
Now, add contract(s) into the collection. To do this, use the command below:
bonadocs collections 0xb52b23ce contracts add
It prompts you to provide the name, network, and address of the contract. This adds the contract to the collection.
P.S: If it can’t load the contract details from the address, you can use the ABI by following these steps:
https://lh7-us.googleusercontent.com/docsz/AD_4nXdeRtCUKUzHCuGcF2PEc4-cxIq_ErLnG5MkIhba7DzFMlkuXf99u4gJjF2JCmbjhx8BPQhw64B0VwzdvDMqlwjVl59dbnZd0jk97pkXqCzFAUldtphQB_a8_59g09TpheuPlQaqsnOR7zYDgtMnVugT45_d?key=fqhk6c6ORhDEI_CDFwy24w
Now, add double quotation marks to the start and end of your escaped ABI ****
Run the following command:
bonadocs collections 0xb52b23ce contracts add —-abi “{escapedABI}”