是的。文本應該是ASCII編碼的,并在交易的資料中以十六進制字元串的形式提供。示例如下:
RawTransaction.createTransaction(
<nonce>, GAS_PRICE, GAS_LIMIT, "0x<address>", <amount>, "0x<hex encoded text>");
byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, ALICE);
String hexValue = Numeric.toHexString(signedMessage);
EthSendTransaction ethSendTransaction =
web3j.ethSendRawTransaction(hexValue).send();
String transactionHash = ethSendTransaction.getTransactionHash();
...
注:請確定你增加了交易的氣體限制,以允許存儲文本。
下面的
stackexchange文章對于了解這個問題很有用。
原文《Java以太坊類庫web3j官網中文翻譯》中的:
http://cw.hubwiz.com/card/c/web3j/1/12/6/另外推薦幾個很受歡迎全網稀缺的互動教程: