【问题标题】:Max string size of Ethereum Contract ABI以太坊合约 ABI 的最大字符串大小
【发布时间】:2017-07-31 02:05:02
【问题描述】:

我正在编写代码以通过 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)

如果我想放置超过 32 字节的字符串,我应该怎么做?会像下面这样吗?

Sample text: "Lorem ipsum dolor sit amet, consectetur posuere."
Text size: 48 bytes

0x0000000000000000000000000000000000000000000000000000000000000030
0x4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73
0x6563746574757220706f73756572652e00000000000000000000000000000000

有人知道吗?

【问题讨论】:

    标签: ethereum json-rpc abi solidity


    【解决方案1】:

    将字符串填充为 32 长度的倍数。

    对于您的情况,您有 48 个字节,因此将其填充为 64 个字节。

    【讨论】:

      猜你喜欢
      • 2016-02-28
      • 1970-01-01
      • 2019-04-07
      • 2018-03-15
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      • 2019-05-09
      • 1970-01-01
      相关资源
      最近更新 更多