How do we convert bytes from encoded number
See original GitHub issueIn substrate(rust), type of encoded value is Vec<u8> and in polkadot-js, type of encoded value is Uint8Array. How to convert a value of type Uint8Array to value of type Vec<u8> or Bytes?
Error code 1
let u8_1 = api.registry.createType("u8", 1).toU8a();
let u32_25 = api.registry.createType("u32", 25).toU8a();
Error message is : mockNumericCondtion: error message is MustBeDecodable,
This error defined
let number: u8 = Decode::decode(&mut &_query[..]).map_err(|_| Error::<T>::MustBeDecodable)?;
Error code 2
let u8_1 = new Bytes(api.registry, api.registry.createType("u8", 1).toU8a());
let u32_25 = new Bytes(api.registry, api.registry.createType("u32", 25).toU8a());
Error message is: UnhandledPromiseRejectionWarning: Error: Bytes: required length less than remainder, expected at least 2, found 1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Number of bytes to encode a number - Stack Overflow
Actually, bytes[0] = 0000 0000 and bytes[1] = 0000 0001 . The number represented by your bytes[] is 511 (decimal). – Stephen C...
Read more >How to Convert Bytes to String in Python ? - GeeksforGeeks
This method is used to convert from one encoding scheme, in which the argument string is encoded to the desired encoding scheme.
Read more >How to convert byte[] array to String in Java - Mkyong.com
In Java, we can use new String(bytes, StandardCharsets.UTF_8) to convert a byte[] to a String . // string to byte[] byte[] bytes =...
Read more >Convert Bytes to a String
Simple, free, and easy to use online tool that converts bytes to a string. No intrusive ads, popups, or nonsense, just a neat...
Read more >How to convert Python string to bytes? | Flexiple Tutorials
#Using the byte() method # initializing string · bytes ; b'Join our freelance network' 74 · 105 ; #Using the encode method #...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It worked 😃 Thank you very much!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.