From 1d606541407b143dad654b8fde27b18f87824d25 Mon Sep 17 00:00:00 2001 From: pasmat Date: Fri, 13 Oct 2023 15:14:16 +0200 Subject: [PATCH] Parameters should be padded to be 32 bytes wide At least binance RPC doesn't work if the parameters aren't padded to be 32 bytes wide as according to the spec https://docs.soliditylang.org/en/latest/abi-spec.html --- src/Abi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Abi.php b/src/Abi.php index 3e3870f..9dcfbae 100644 --- a/src/Abi.php +++ b/src/Abi.php @@ -46,7 +46,7 @@ public function encodeFunction(string $methodName, array $values) foreach ($values as $i => $val) { $expectedType = $m->inputs[$i]->type; $validAbiType = self::convertByAbi($expectedType, $val); - $params .= EthereumStatic::removeHexPrefix($validAbiType->encodedHexVal()); + $params .= str_pad(EthereumStatic::removeHexPrefix($validAbiType->encodedHexVal()), 64, "0", STR_PAD_LEFT); } return new EthD($params); }