hashgraph / hashgraph/hedera-docs

Add example for how to deserialize a base64 encoded binary protobuf data.

Open
#16 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
MDX
Stars
10
Forks
49
Avg merge
19h 49m
Merged PRs (30d)
17

Description

### Problem

The mirror node API response for scheduled includes a transaction body that is in base64 encoded binary protobuf format. Devs should have an example for how to deserialize this data.

```
import { proto } from "@hashgraph/proto";

const encodedString =
"CIDh6xcSHlNlbnQgdmlhIEhhc2hQYWNrIFNlY3VyZSBUcmFkZUo3ChgKCgoDGLsKEP+Dr18KCgoDGO8LEICEr18SGwoFGPTl3gISCAoDGLsKEMcBEggKAxjvCxDIAQ==";

// Decode the Base64 string into a binary string
const binaryString = atob(encodedString);

// Convert the binary string to a byte array
const byteArray = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
byteArray[i] = binaryString.charCodeAt(i);
}

console.log(proto.SchedulableTransactionBody.decode(byteArray));
```

### Solution

Add example/tutorial

### Alternatives

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.