Skip to content

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

bash
bb tx tokenization set-setcustomdata ./set-custom-data.json --from alice --chain-id bitbadges-1
ts
import { 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);
json
{
  "creator": "bb1p0rrel3365scadq5k9pv0x0zp9j22js6dnw70d",
  "collectionId": "1",
  "customData": "{\"website\":\"https://bitbadges.io\",\"version\":\"1.0\"}",
  "canUpdateCustomData": [
    {
      "permanentlyPermittedTimes": [{ "start": "1", "end": "18446744073709551615" }],
      "permanentlyForbiddenTimes": []
    }
  ]
}

Fields

FieldTypeRequiredDescription
creatorstringyesSigner. Must be the current manager.
collectionIdUintyesCollection to update.
customDatastringyesArbitrary string. Often JSON.
canUpdateCustomDataActionPermission[]noNew permission.

The response contains collectionId.

Behavior

  • Builds a MsgUniversalUpdateCollection with updateCustomData: true and updateCollectionPermissions: true. Every other permission is copied from the stored collection.
  • The change is checked against the stored canUpdateCustomData for the current time.
  • Errors: ErrCollectionNotExists, ErrSenderIsNotManager, ErrCollectionIsArchived, permission forbidden.

Edit this page on GitHub