MCPcopy Create free account
hub / github.com/CashScript/cashscript / getPushDataOpcode

Function getPushDataOpcode

packages/utils/src/script.ts:144–151  ·  view source on GitHub ↗
(data: Uint8Array)

Source from the content-addressed store, hash-verified

142}
143
144function getPushDataOpcode(data: Uint8Array): Uint8Array {
145 const { byteLength } = data;
146
147 if (byteLength === 0) return Uint8Array.from([0x4c, 0x00]);
148 if (byteLength < 76) return Uint8Array.from([byteLength]);
149 if (byteLength < 256) return Uint8Array.from([0x4c, byteLength]);
150 throw Error('Pushdata too large');
151}
152
153export function generateContractBytecodeScript(baseScript: Script, encodedConstructorArgs: Script): Script {
154 return [...encodedConstructorArgs.slice().reverse(), ...baseScript];

Callers 1

encodeNullDataScriptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected