aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src/abi_encoder/evm_data_types.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/utils/src/abi_encoder/evm_data_types.ts')
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/packages/utils/src/abi_encoder/evm_data_types.ts b/packages/utils/src/abi_encoder/evm_data_types.ts
index 38878f63e..ff1bc594d 100644
--- a/packages/utils/src/abi_encoder/evm_data_types.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types.ts
@@ -270,6 +270,10 @@ export class Byte extends PayloadDataType {
}
public encodeValue(value: string | Buffer): Buffer {
+ // Sanity check if string
+ if (typeof value === 'string' && value.startsWith('0x') === false) {
+ throw new Error(`Tried to encode non-hex value. Value must inlcude '0x' prefix.`);
+ }
// Convert value into a buffer and do bounds checking
const valueBuf = ethUtil.toBuffer(value);
if (valueBuf.byteLength > this.width) {