export function getBlockBytes(blockId: string) : Buffer{ if(!blockId.startsWith("0x") && blockId.length != 33){ throw Error("Invalid address format"); } let blockIdHex = blockId.slice(2); let blockIdBytes = StringToByteArray(blockIdHex).slice(0,8); while(blockIdBytes[0] == 0){ blockIdBytes = blockIdBytes.slice(1); } return blockIdBytes; } function StringToByteArray(data: string): Buffer{ let result = []; for(var i = 0; i< data.length; i+=2){ result.push(parseInt(data.substr(i,2),16)); } return Buffer.from(result); }