I am using the openbrush standard to implement a psp34 token. Now I want to call certain methods from said token, like for example owner_of.

owner_of from psp34 has id:Id as an input which can then be defined as U8, U16, U32, U64, U128 or Bytes.

The input on the JavaScript side is a String like this:

const id = '0xf59eee94f32bfeddeca43d100742db523b5d00041d2314512c37c663e3404c68'

and now I want to call the owner_of method, using said Id. This results in this error:

Uncaught (in promise) Error: createType(OpenbrushContractsTypesId):: Unable to create Enum via index 237, in U8, U16, U32, U64, U128, Bytes

I tried to use the createType package of polkadot like this:

const input = api.createType('Bytes', id)

But it results in the same error. How can I cast my String input to 'Bytes' so it will be accepted by the api?

1 Answer 1


For any enum, the input is index + bytes. So depending on the enum, the first byte needs to be the actual enum id or (in the case of the JS API) identify the enum, type.

Since you have no info, some examples that may or may not be applicable -

// pass u16 to query
api.query.<somewhere>.ownerOf({ u16: '0xf59eee94f32bfeddeca43d100742db523b5d00041d2314512c37c663e3404c68' })

// pass u32 to tx
api.tx.<somewhere>.ownerOf({ u32: '0xf59eee94f32bfeddeca43d100742db523b5d00041d2314512c37c663e3404c68' })

etc... You need to identify where the enum points.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.