简体   繁体   中英

Max string size of Ethereum Contract ABI

I am writing code to communicate deployed ethereum contract through JSON-RPC. When I call eth_call, I need to prepare data set for it. Although this link has details but I got a question when I read dynamic sized unicode string part.It says

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)

If I want to put strings over 32byte, what should I do? Will it be like following?

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

0x0000000000000000000000000000000000000000000000000000000000000030
0x4c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73
0x6563746574757220706f73756572652e00000000000000000000000000000000

Does anybody know this?

Pad the string to multiple of 32 length.

For your case you've 48 bytes, so pad it to 64 bytes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM