Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TODO: imports and functions goes here
- export const myblockchainCodec: TxCodec = {
- /** these are the bytes we create to add a signature;
- * they often include nonce and chainID */
- bytesToSign: (unsigned: UnsignedTransaction, nonce: Nonce): SigningJob => {
- // TODO: write your unsigned transaction serialization recipe
- return {
- bytes, /** the serialized transaction */
- prehashType /** your crypto flawor from PrehashType: Sha256, Sha512, Keccak256 */
- };
- },
- /** bytesToPost includes the raw transaction appended with the various signatures */
- bytesToPost: (signed: SignedTransaction): PostableBytes => {
- // TODO: write your signed transaction serialization recipe
- return mySignedTxSerializedBytes as PostableBytes;
- },
- /** identifier is usually some sort of hash of bytesToPost, chain-dependent */
- identifier: (signed: SignedTransaction): TransactionId => {
- // TODO: generate your transaction id
- return myTransactionId as TransactionId;
- },
- /** parseBytes will recover bytes from the blockchain into a format we can use */
- parseBytes: (bytes: PostableBytes, chainId: ChainId): SignedTransaction => {
- // TODO: deserialize your transaction bytes into the readable components
- return myHumanReadTransaction as SignedTransaction;
- },
- /** chain-dependent way to calculate address from a public key */
- identityToAddress: (identity: PublicIdentity): Address => {
- // TODO: logic to get from public key to blockchain address
- return myAddressFromPubKey as Address;
- },
- /** chain-dependent validation of address */
- isValidAddress: (address: string): boolean => {
- // TODO: logic to validate an address
- return myAddressValidationBoolean;
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement