MsgSetCustomData
MsgSetCustomData sets a collection's customData string and the canUpdateCustomData permission in one message.
Sets the collection-level customData string and the permission that guards future changes. Only the current manager can sign it. For multi-field updates use MsgUpdateCollection.
Example
bb tx tokenization set-setcustomdata ./set-custom-data.json --from alice --chain-id bitbadges-1import { BitBadgesSigningClient, GenericCosmosAdapter, MsgSetCustomData } from 'bitbadges';
const adapter = await GenericCosmosAdapter.fromMnemonic(process.env.MNEMONIC!, 'bitbadges-1');
const client = new BitBadgesSigningClient({ adapter, network: 'mainnet' });
const msg = new MsgSetCustomData({
creator: 'bb1p0rrel3365scadq5k9pv0x0zp9j22js6dnw70d',
collectionId: 1n,
customData: '{"website":"https://bitbadges.io","version":"1.0"}',
canUpdateCustomData: [
{
permanentlyPermittedTimes: [{ start: 1n, end: 18446744073709551615n }],
permanentlyForbiddenTimes: []
}
]
});
const result = await client.signAndBroadcast([msg]);
console.log(result.txHash, result.success);{
"creator": "bb1p0rrel3365scadq5k9pv0x0zp9j22js6dnw70d",
"collectionId": "1",
"customData": "{\"website\":\"https://bitbadges.io\",\"version\":\"1.0\"}",
"canUpdateCustomData": [
{
"permanentlyPermittedTimes": [{ "start": "1", "end": "18446744073709551615" }],
"permanentlyForbiddenTimes": []
}
]
}Fields
| Field | Type | Required | Description |
|---|---|---|---|
creator | string | yes | Signer. Must be the current manager. |
collectionId | Uint | yes | Collection to update. |
customData | string | yes | Arbitrary string. Often JSON. |
canUpdateCustomData | ActionPermission[] | no | New permission. |
The response contains collectionId.
Behavior
- Builds a MsgUniversalUpdateCollection with
updateCustomData: trueandupdateCollectionPermissions: true. Every other permission is copied from the stored collection. - The change is checked against the stored
canUpdateCustomDatafor the current time. - Errors:
ErrCollectionNotExists,ErrSenderIsNotManager,ErrCollectionIsArchived, permission forbidden.