# BitBadges bindings for CosmWasm
This crate provides the custom bindings that are used to communicate with the custom modules (x/badges) on the BitBadges network from a CosmWasm smart contract.
# Installation
Add the crate to your smart contract's' Cargo.toml
toml
[dependencies]
bitbadges-cosmwasm = { version = "X.X.X" }
# Exposed bindings This crate, as of now, exports binding only for the x/badges module. In the future, more custom binding will be added.
NOTE: The BitBadges bindings do not cover messages that have already been implemented by the CosmWasm team, such as staking-related messages and fundamental ones like MsgSend
.
You may want your contract to perform messages such as MintBadge
and RegisterAddresses
operations at the end of its execution. To do this, create a message using the predefined functions:
- create_register_addresses_msg
- ...
And add it to your response, like below
```rust
use cosmwasmstd::CosmosMsg;
use bitbadgescosmwasm::{createregisteraddressesmsg};
...
pub fn executemsgregisteraddresses(
deps: DepsMut
Ok(Response::new().add_message(msg))
} ```
In order to use the query functions enabled by the bindings, create a BitBadgesQuerier
instance within your contract logic -- in either init()
or query()
entrypoints. You can access all the enabled queries through this object.
```rust
// src/contract.rs
use bitbadgescosmwasm::{ BitBadgesQuerier };
...
pub fn querycollection(deps: Deps, id: u64) -> StdResult
Ok(res)
}
```
Please consult the example smart contracts in /contracts - there you can see an example how to issue a transaction or make a query from the smart contract to the custom module. You can upload it and interact with it (and through it - with the bitbadges chain) with the following steps. This assumes you have a local bitbadges chain running.
```bash clonedDir='path/to/the/test/smart/contract/binary' bitbadgeschaind tx wasm store $clonedDir/bindings_tester.wasm --from=
--chain-id=bitbadgeschaind tx wasm instantiate yourcodeid $INIT --from=
--label="your_label" --chain-id=msgDetails='{ "registerAddressesMsg": { "addressesToRegister": [ "cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl" ] } }' bitbadgeschaind tx wasm execute $TESTER $msgDetails --from=
--chain-id=This repository was forked form the Cudos cosmwasm bindings. We would like to thank the Cudos team for their work on this project.