我正在编写代码以通过JSON-RPC传达已部署的以太坊契约。当我调用eth_call时,我需要为它准备数据集。虽然this link有详细信息但我在阅读动态大小的unicode字符串部分时遇到了一个问题。它说
Finally, we encode the data part of the second dynamic argument, "Hello, world!":
0x000000000000000000000000000000000000000000000000000000000000000d
(number of elements (bytes in this case): 13)
0x48656c6c6f2c20776f726c642100000000000000000000000000000000000000
("Hello, world!" padded to 32 bytes on the right)
如果我想将字符串放在32byte上,我该怎么办?它会像跟随吗?
Sample text: "Lorem ipsum dolor sit amet, consectetur posuere."
Text size: 48 bytes
0x0000000000000000000000000000000000000000000000000000000000000030
0x4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73
0x6563746574757220706f73756572652e00000000000000000000000000000000
有人知道吗?
答案 0 :(得分:0)
将字符串填充为32个长度的倍数。
对于你的情况,你有48个字节,所以将它填充到64个字节。